You are on page 1of 52

4BUIS015C.

2 Database Design
and Implementation.

Coursework.

Lecturer Name: - Ms. Yaalini Balathasan.

M. M. A. Uvindu Sandasara.
Blackboard Name: - Men Sandasara.
UOW ID: W2087738
IIT No: 20221297
Men Sandasara UOW No: W2087738 / IIT No: 20221297

Acknowledgment.
I sincerely appreciate Ms. Yaalini Balathasan, our lecturer, for his wise counsel and the clear
learning about to create database and SQL. Her commitment to creating a supportive learning
environment has greatly influenced how well we understand the subject.
I would also like to express gratitude to our tutorial lecturers Ms. Gayathri Senevirathne, and Ms.
Janadhi Weranja for their passion and commitment to teaching. Their thought-provoking and
captivating lectures have enhanced my education and motivated me to learn more about the
Subject.
And I want to express our gratitude to my parents for their unwavering love, sacrifices, and
support, all of which have made it possible for me to pursue my education. I am grateful for their
unwavering belief in me, which has continuously inspired me.

4BUIS015C.2 Database Design and Implementation| [ 4BUIS015C]


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Table of Contents
Acknowledgment. ........................................................................................................................................ 2
List of Figures.............................................................................................................................................. 4
Problem. ....................................................................................................................................................... 1
01. ER Diagram. ................................................................................................................................... 3
Notes. ............................................................................................................................................... 5
Visualizing System Entities and Relationships. ........................................................................... 5
Assumptions. .................................................................................................................................. 6
02. DDL Statements with Insert Data. ............................................................................................... 7
03. SQL table creation and Data entering Scripts. ......................................................................... 14
Create ‘The Disaster Management System’ database................................................................. 14
Create Disaster Event table, Inserting data, and Structure output. ............................................... 15
Create Disaster Management table, Inserting data, and Structure output.................................... 17
Create Donation event table, Inserting data, and Structure output. .............................................. 19
Create Donor table, Inserting data, and Structure output. ............................................................. 21
Create Man Made disaster table, Inserting data, and Structure output. ....................................... 23
Create Natural disaster table, Inserting data, and Structure output. ............................................ 25
Create Person table, Inserting data, and Structure output............................................................. 27
Create Relief camp, Inserting data, and Structure output. ............................................................ 29
Create Volunteer, Inserting data, and Structure output................................................................. 31
04. Ten SQL query scripts................................................................................................................. 33
05. Ten SQL queries and Output...................................................................................................... 35
Query 01................................................................................................................................................. 35
Query 02................................................................................................................................................. 36
Query 03................................................................................................................................................. 37
Query 04................................................................................................................................................. 38
Query 05................................................................................................................................................. 39
Query 06................................................................................................................................................. 40
Query 07................................................................................................................................................. 41
Query 08................................................................................................................................................. 42
Query 09................................................................................................................................................. 43
Query 10................................................................................................................................................. 44
Conclusion. ................................................................................................................................................ 47

4BUIS015C.2 Database Design and Implementation| [ 4BUIS015C]


Men Sandasara UOW No: W2087738 / IIT No: 20221297

List of Figures.
Figure 1 - ER Diagram. ................................................................................................................... 3
Figure 2 - Create Database. ........................................................................................................... 14
Figure 3 - Structure of database DMS. ......................................................................................... 14
Figure 4 - Creating disaster event database. ................................................................................. 15
Figure 5 - Proof of creating disaster event database. .................................................................... 15
Figure 6 – Inserting data for disaster event. .................................................................................. 16
Figure 7 – Proof of inserting disaster event data. ......................................................................... 16
Figure 8 – Structure output of disaster event database. ................................................................ 17
Figure 9 – Create disaster management database. ........................................................................ 17
Figure 10 – Proof of creating disaster management database. ...................................................... 18
Figure 11 – inserting data for disaster management. .................................................................... 18
Figure 12 – Proof of inserting disaster management data. ............................................................ 18
Figure 13 – structure output of disaster management database. ................................................... 19
Figure 14 – Creating Donation event database. ............................................................................ 19
Figure 15 – Proof of Creating donation event database. ............................................................... 20
Figure 16 – inserting donation event data. .................................................................................... 20
Figure 17 - Proof of inserting donation event data. ...................................................................... 20
Figure 18 - structure output of donation event database. .............................................................. 21
Figure 19 - Create Donor database. .............................................................................................. 21
Figure 20 - Proof of creating donor database. ............................................................................... 22
Figure 21 - inserting donor data. ................................................................................................... 22
Figure 22 - Proof of inserting donor data. ..................................................................................... 22
Figure 23 - Structure output of donor database............................................................................. 23
Figure 24 - Create Man made disaster database. .......................................................................... 23
Figure 25 - Proof of Creating man-made disaster database. ......................................................... 24
Figure 26 - Inserting man-made disaster data. .............................................................................. 24
Figure 27 - Proof of inserting man-made disaster data. ................................................................ 24
Figure 28 - structure output of man-made disaster database. ....................................................... 25
Figure 29 - creating natural disaster database. .............................................................................. 25
Figure 30 - Proof of creating natural disaster database. ................................................................ 26
Figure 31 - Inserting natural disaster data. .................................................................................... 26
Figure 32 - Proof of inserting natural disaster data. ...................................................................... 26
Figure 33 - structure output of natural disaster database. ............................................................. 27
Figure 34 - Creating person database. ........................................................................................... 27
Figure 35 - Proof creating person database. .................................................................................. 28
Figure 36 - Inserting person data. ................................................................................................. 28
Figure 37 - Proof of inserting person data. ................................................................................... 28
Figure 38 - structure output of person database. ........................................................................... 29
Figure 39 - Creating relief camp database. ................................................................................... 29

4BUIS015C.2 Database Design and Implementation| [ 4BUIS015C]


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Figure 40 - proof creating relief camp database. .......................................................................... 29


Figure 41 - Inserting relief camp data. .......................................................................................... 30
Figure 42 - proof inserting relief camp data. ................................................................................ 30
Figure 43 - structure output of relief camp data. ........................................................................... 30
Figure 44 - Creating Volunteer database. ..................................................................................... 31
Figure 45 - Proof creating volunteer database. ............................................................................. 31
Figure 46 - Inserting volunteer data. ............................................................................................. 31
Figure 47 - Proof inserting volunteer data. ................................................................................... 32
Figure 48 – structure output of volunteer database. ...................................................................... 32
Figure 49 - Query 01 code. ........................................................................................................... 35
Figure 50 - Query 01 Output. ........................................................................................................ 35
Figure 51 - Query 02 code. ........................................................................................................... 36
Figure 52 - Query 02 output. ......................................................................................................... 36
Figure 53 - Query 03 code. ........................................................................................................... 37
Figure 54 - Query 03 output. ......................................................................................................... 37
Figure 55 - Query 04 code. ........................................................................................................... 38
Figure 56 - Query 04 output. ......................................................................................................... 38
Figure 57 - Query 05 code. ........................................................................................................... 39
Figure 58 - Query 05 output. ......................................................................................................... 39
Figure 59 - Code 06 code. ............................................................................................................. 40
Figure 60 - Query 06 output. ......................................................................................................... 40
Figure 61 - Query 07 code. ........................................................................................................... 41
Figure 62 - Query 07 output. ......................................................................................................... 41
Figure 63 - Query 08 code. ........................................................................................................... 42
Figure 64 - Query 08 output. ......................................................................................................... 42
Figure 65 - Query 09 code. ........................................................................................................... 43
Figure 66 - Query 09 output. ......................................................................................................... 43
Figure 67 - Query 10 code. ........................................................................................................... 44
Figure 68 - Query 10 output. ......................................................................................................... 44

4BUIS015C.2 Database Design and Implementation| [ 4BUIS015C]


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Problem.
Coursework Case Study - The Disaster Management System.
Sri Lanka, being a tropical island in the Indian Ocean, is prone to various natural disasters such as
floods, landslides, cyclones, and droughts. The Disaster Management System (DMS) is a network
responsible for managing and mitigating these disasters.
Each disaster event is recorded with unique characteristics such as a unique identification number,
the type of disaster (flood, landslide, cyclone, drought, etc.), the date it occurred, the regions
affected, the severity level, and the estimated damage cost.
Disaster events in the DMS’s records are further classified into two categories: those that are
natural disasters, with associated information including the meteorological data, geological data,
and the predicted frequency; and those that are man-made disasters, with relevant details including
the cause, the responsible parties, and the preventive measures.
The DMS meticulously maintains records of relief camps set up during these disasters, capturing
essential information including their name, location, capacity, the number of people
accommodated, the supplies available, and a contact person. It is assumed that each relief camp’s
name is unique.
Moreover, the DMS organizes various disaster management programs throughout the year. Each
of these programs is defined by a distinctive name, a commencement date, and an end date. These
programs are intrinsically linked to the disaster events they are designed to manage, forming a
dynamic and ever-evolving showcase of disaster management initiatives.
Volunteers play a crucial role in disaster management. Each volunteer is identified by a unique ID,
and their details such as name, contact information, and area of expertise are recorded. A single
relief camp can have multiple volunteers, and a volunteer can work in multiple relief camps.
Donors contribute to disaster management efforts by providing funds or supplies. Each donor is
identified by a unique ID, and their details such as name, contact information, and type of donation
are recorded. A single disaster event can have multiple donors, and a donor can contribute to
multiple disaster events.
Your task as a junior database developer at DMS is to design and develop a database system for
this problem.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 1


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Task details:
1. You are required to produce an ERD (Entity Relationship Diagram) for the case study
given using UML notation, any other notation will not be graded.
2. The ERD should represent aspects related to The Disaster Management System only.
3. For each of the entities in your model, you should clearly identify appropriate attributes
and relevant keys.
4. Relationships between entities should be clearly identified and labelled with any
assumptions fully documented.
5. You are also required to implement your design as a relational database using MySQL
database by creating appropriate SQL scripts and executing them.
6. You should populate your tables with sufficient data to demonstrate the execution of ten
relevant and useful queries.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 2


Men Sandasara UOW No: W2087738 / IIT No: 20221297

01. ER Diagram.

Figure 1 - ER Diagram.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 3


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Entity Primary Key Foreign Key (FK) Rational for PK


(PK)

Disaster Event EventID N/A Unique identifier for


each disaster event.

Disaster management ProgramName N/A Each disaster


management program
has a unique name.

Donation event DonationEvent_ID DonorUniqueID Unique identifier for


each donation event.

donor DonorUniqueID N/A Unique identifier for


each donor.

Man made disasters EventID N/A Unique identifier for


each man-made
disaster.

Natural disasters EventID N/A Unique identifier for


each natural disaster.

Relief camp Name N/A Unique name of each


relief camp.

person Name N/A Unique name of each


person involved.

volunteer VolunterID N/A Unique identifier for


each volunteer.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 4


Men Sandasara UOW No: W2087738 / IIT No: 20221297

❖ Notes.

a) Primary Keys (PK) are unique identifiers for each entity.


b) Foreign Keys (FK) are attributes that link an entity to another entity's (PK).
c) Relationships should have cardinality (one-to-one, one-to-many, many-to-many) and
participation.

❖ Visualizing System Entities and Relationships.

(1) indicates a one-to-one relationship. (*) indicates a one-to-many relationship. (0, *) indicates
zero or many relationships.
i. Disaster Event
➢ A disaster event can be either a natural disaster or a man-made disaster. It has a
one-to-one relationship with both entities.
ii. Natural Disasters
➢ A natural disaster is a type of disaster event.
iii. Man Made Disasters
➢ A man-made disaster is also a type of disaster event.
iv. Disaster Management
➢ A disaster management program can manage multiple disaster events.
v. Relief Camp
➢ A relief camp is associated with one or more disaster events.
➢ A relief camp may have volunteers assisting in its operation.
vi. Person
➢ A person can be a volunteer for multiple relief camps.
vii. Volunteer
➢ A volunteer can work at one or more relief camps.
viii. Donation Event
➢ A donation event is associated with one or more donors.
ix. Donor
➢ A donor can make donations at multiple donation events.
Using UML notation and connecting the entities with the proper cardinality indicators to indicate
the relationships' nature, we may depict these relationships in the ERD with these linkages in mind.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 5


Men Sandasara UOW No: W2087738 / IIT No: 20221297

❖ Assumptions.

I. Disaster event, whether Natural Disaster or Man-Made Disaster, is documented with a


unique EventID and relevant details such as type, data, severity level, and estimated
damage cost.
II. Natural Disasters are characterized by meteorological and geological data, along with
predicted frequencies, providing insights into their occurrence patterns.
III. Man-made Disaster are identified by their causes, responsible parties, and preventive
measures, facilitating proactive management strategies.
IV. Disaster management programs, with unique names and defined start and end dates,
oversee and coordinate response efforts for multiple disaster events,
V. Relief camps, identifiable by their unique names, are strategically located to provide
shelter, supplies, and assistance to affected populations during disaster events.
VI. Donation events serve as platforms for mobilizing resources, with donors providing various
types of aid, including supplies, funds, and services, to support relief activities.
VII. Donors, with unique identifiers, contribute to multiple donation events, demonstrating a
commitment to supporting disaster response and recovery efforts.
VIII. Supplies available at relief camps are managed and distributed efficiently to meet the needs
of affected individuals and communities, ensuring timely and effective assistance.
IX. Volunteers contribute their expertise and time to support relief operations at one or more
relief camps, bringing diverse skills and abilities to the response efforts.
X. Individuals involved in disaster relief efforts, including volunteers and donors are
registered with their names and contact information for coordination purposes.
XI. The collaboration and coordination among various entities, including disaster management
programs, relief camps, volunteers, and donors, facilitate a comprehensive and efficient
response to disaster events, minimizing their impact on affected populations.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 6


Men Sandasara UOW No: W2087738 / IIT No: 20221297

02. DDL Statements with Insert Data.


-- Table structure for table `disaster_event` --
CREATE TABLE `disaster_event` (
`EventID` int(12) NOT NULL,
`Type` varchar(50) DEFAULT NULL,
`Date` date DEFAULT NULL,
`SeverityLevel` varchar(30) DEFAULT NULL,
`EstimatedDamageCost` decimal(10,2)
);

-- Inserting data for table `disaster_event`--


INSERT INTO `disaster_event` (`EventID`, `Type`, `Date`, `SeverityLevel`,
`EstimatedDamageCost`) VALUES
(1, 'Flood', '2023-07-15', 'High', '100000.00'),
(2, 'Landslide', '2023-08-20', 'Medium', '50000.00'),
(3, 'Tornado', '2023-10-05', 'High', '200000.00'),
(4, 'Cyclone', '2023-11-25', 'Extreme', '500000.00'),
(5, 'Wildfire', '2023-12-12', 'Medium', '75000.00'),
(6, 'Gas Explotion', '2023-03-20', 'High', '1000000.00'),
(7, 'Industrial Accident', '2023-01-10', 'Extreme', '300000.00')
(8, 'oil Spill', '2024-02-25', 'High', '25000000.00')
(9, 'Gem Mining', '2024-02-20', 'Extreme', '1000000.00')
(10, 'Factory Explosion', '2023-12-19', 'High', '3000000.00');

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 7


Men Sandasara UOW No: W2087738 / IIT No: 20221297

-- Table structure for table `disaster_management` --


CREATE TABLE `disaster_management` (
`ProgramName` varchar(200) NOT NULL,
`StartingDate` date DEFAULT NULL,
`EndingDate` date DEFAULT NULL
);

-- Inserting data for table `disaster_management` --


INSERT INTO `disaster_management` (`ProgramName`, `StartingDate`, `EndingDate`)
VALUES
('Cyclone Evacuation 2023', '2023-07-05', '2023-07-10'),
('Landslide Monitoring Project 2023', '2023-09-15', '2023-11-15'),
('Flood Relief 2023', '2023-05-20', '2023-06-20'),
('Landslide Recovery 2023', '2023-08-25', '2023-09-25'),
('Wildfire Prevention 2023', '2023-10-15', '2023-11-15');

-- Table structure for table `donation_event` --


CREATE TABLE `donation_event` (
`DonationEventID` int(12) NOT NULL,
`DonorUniqueID` int(12) DEFAULT NULL
);

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 8


Men Sandasara UOW No: W2087738 / IIT No: 20221297

-- Insterting data for table `donation_event` --


INSERT INTO `donation_event` (`DonationEventID`, `DonorUniqueID`) VALUES
(1, 1),
(2, 2),
(3, 3),
(4, 4),
(5, 5);

-- Table structure for table `donor` --


CREATE TABLE `donor` (
`DonorUniqueID` int(12) NOT NULL,
`Name` varchar(100) DEFAULT NULL,
`ContactNo1` varchar(20) DEFAULT NULL,
`ContactNo2` varchar(20) DEFAULT NULL,
`ContactNo3` varchar(20) DEFAULT NULL,
`TypeOfDonation` varchar(100) DEFAULT NULL
);

-- Inserting data for table `donor` --


INSERT INTO `donor` (`DonorUniqueID`, `Name`, `ContactNo1`, `ContactNo2`, `ContactNo3`,
`TypeOfDonation`) VALUES
(1, 'Jerum Fanando', '94765656560', NULL, '94763537687', 'Monetary'),
(2, 'Alwis Perera', '94715869321', NULL, '94708800048', 'Supplies'),
(3, 'Wikum rajapaksha', '94768000565', NULL, '94712626968', 'Food supplies'),
(4, 'Damith Kodikara', '94765252600', NULL, '94762006368', 'Clothing'),
(5, 'Aksha Sarojanee', '94710000526', NULL, '94708341988', 'Medical equipment');

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 9


Men Sandasara UOW No: W2087738 / IIT No: 20221297

-- Table structure for table `man_made_disasters` --


CREATE TABLE `man_made_disasters` (
`EventID` int(12) NOT NULL,
`Cause` varchar(100) DEFAULT NULL,
`ResponsibilityParties` varchar(300) DEFAULT NULL,
`PreventiveMeasure` varchar(400) DEFAULT NULL
);

-- Inserting data for table `man_made_disasters` --


INSERT INTO `man_made_disasters` (`EventID`, `Cause`, `ResponsibilityParties`,
`PreventiveMeasure`) VALUES
(6, 'Gas explosion', 'Construction company', 'Regular maintenance checks'),
(7, 'Chemical spill', 'Chemical manufacturing plant', 'Implementing safety protocols and regular
inspections'),
(8, 'Structural collapse', 'Engineering firm', 'Structural integrity assessments and reinforcement
measures'),
(9, 'Power outage', 'Utility company', 'Backup power systems and infrastructure maintenance')
(10, 'Urban Fire', 'Negligence', 'Fire safety awareness and building codes');

-- Table structure for table `natural_disasters` --


CREATE TABLE `natural_disasters` (
`EventID` int(12) NOT NULL,
`MeteorologicalData` varchar(200) DEFAULT NULL,
`GeologicalData` varchar(200) DEFAULT NULL,
`PredictedFrequency` int(12) DEFAULT NULL
);

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 10


Men Sandasara UOW No: W2087738 / IIT No: 20221297

-- Inserting data for table `natural_disasters` --


INSERT INTO `natural_disasters` (`EventID`, `MeteorologicalData`, `GeologicalData`,
`PredictedFrequency`) VALUES
(1, 'Wildfire', 'Dry conditions, high winds', 0),
(2, 'Flood', 'Heavy rainfall, river overflow', 0),
(3, 'Heavy rainfall, 500mm', 'Low elevation, flat terrain', 0),
(4, 'High rainfall, deforested areas', 'Hilly terrain, loose soil', 0),
(5, 'Low rainfall, -70% average', 'Arid region, high evaporation', 0);

-- Table structure for table `person` --


CREATE TABLE `person` (
`Name` varchar(200) NOT NULL,
`VolunteerID` int(12) DEFAULT NULL
);

-- Inserting data for table `person` --


INSERT INTO `person` (`Name`, `VolunteerID`) VALUES
('Sadun', 1),
('Sameera', 2),
('Alwis', 3),
('Surani', 4),
('Heshan', 5);

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 11


Men Sandasara UOW No: W2087738 / IIT No: 20221297

-- Table structure for table `relief_camp` --


CREATE TABLE `relief_camp` (
`Name` varchar(100) NOT NULL,
`Location` varchar(100) DEFAULT NULL,
`Capacity` int(11) DEFAULT NULL,
`NumberOfPeopleAccommodated` int(11) DEFAULT NULL,
`SuppliesAvailable` varchar(100) DEFAULT NULL,
`PersonName` varchar(100) DEFAULT NULL
);

-- Inserting data for table `reliefcamp` --


INSERT INTO `relief_camp` (`Name`, `Location`, `Capacity`,
`NumberOfPeopleAccommodated`, `SuppliesAvailable`, `PersonName`) VALUES
('Camp A', 'Colombo', 800, 500, 'Food, Water, Medicine', 'Alwis Perera'),
('Camp B', 'Polonnaruwa', 300, 250, 'Food, Water, Tents', 'Indunil Kumara'),
('Camp C', 'Galle', 350, 150, 'Medicine, Clothes', 'Anura Rajapaksha'),
('Camp D', 'Anuradhapura', 900, 600, 'Food, Water, Clothes, Medicine', 'Pasan Bandara'),
('Camp E', 'Jaffna', 400, 200, 'Food, Water, Sanitary Supplies', 'Rohan Rajkumar');

-- Table structure for table `volunteer` --


CREATE TABLE `volunteer` (
`VolunteerID` int(11) NOT NULL,
`Name` varchar(100) DEFAULT NULL,
`ContactNo1` varchar(20) DEFAULT NULL,
`ContactNo2` varchar(20) DEFAULT NULL,
`AreaExpertise` varchar(100) DEFAULT NULL
);

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 12


Men Sandasara UOW No: W2087738 / IIT No: 20221297

-- Inserting data for table `volunteer` --


INSERT INTO `volunteer` (`VolunteerID`, `Name`, `ContactNo1`, `ContactNo2`,
`AreaExpertise`) VALUES
(1, 'John Doe', '9476656560', '94763537687', 'Medical Assistance'),
(2, 'Alice Smith', '94715869321', '94708800048', 'Logistics'),
(3, 'Emily Johnson', '94768000565', '94712626968', 'Emergency Helper'),
(4, 'Michael Brown', '94765252600', '94762006368', 'Water Purification'),
(5, 'David Wilson', '94710000526', '94708341988', 'Food Distribution');

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 13


Men Sandasara UOW No: W2087738 / IIT No: 20221297

03. SQL table creation and Data entering


Scripts.

Create ‘The Disaster Management System’ database.

Figure 2 - Create Database.

Figure 3 - Structure of database DMS.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 14


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Create Disaster Event table, Inserting data, and Structure output.

Figure 4 - Creating disaster event database.

Figure 5 - Proof of creating disaster event database.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 15


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Figure 6 – Inserting data for disaster event.

Figure 7 – Proof of inserting disaster event data.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 16


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Figure 8 – Structure output of disaster event database.

Create Disaster Management table, Inserting data, and Structure output.

Figure 9 – Create disaster management database.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 17


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Figure 10 – Proof of creating disaster management database.

Figure 11 – inserting data for disaster management.

Figure 12 – Proof of inserting disaster management data.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 18


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Figure 13 – structure output of disaster management database.

Create Donation event table, Inserting data, and Structure output.

Figure 14 – Creating Donation event database.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 19


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Figure 15 – Proof of Creating donation event database.

Figure 16 – inserting donation event data.

Figure 17 - Proof of inserting donation event data.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 20


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Figure 18 - structure output of donation event database.

Create Donor table, Inserting data, and Structure output.

Figure 19 - Create Donor database.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 21


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Figure 20 - Proof of creating donor database.

Figure 21 - inserting donor data.

Figure 22 - Proof of inserting donor data.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 22


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Figure 23 - Structure output of donor database.

Create Man Made disaster table, Inserting data, and Structure output.

Figure 24 - Create Man made disaster database.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 23


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Figure 25 - Proof of Creating man-made disaster database.

Figure 26 - Inserting man-made disaster data.

Figure 27 - Proof of inserting man-made disaster data.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 24


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Figure 28 - structure output of man-made disaster database.

Create Natural disaster table, Inserting data, and Structure output.

Figure 29 - creating natural disaster database.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 25


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Figure 30 - Proof of creating natural disaster database.

Figure 31 - Inserting natural disaster data.

Figure 32 - Proof of inserting natural disaster data.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 26


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Figure 33 - structure output of natural disaster database.

Create Person table, Inserting data, and Structure output.

Figure 34 - Creating person database.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 27


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Figure 35 - Proof creating person database.

Figure 36 - Inserting person data.

Figure 37 - Proof of inserting person data.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 28


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Figure 38 - structure output of person database.

Create Relief camp, Inserting data, and Structure output.

Figure 39 - Creating relief camp database.

Figure 40 - proof creating relief camp database.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 29


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Figure 41 - Inserting relief camp data.

Figure 42 - proof inserting relief camp data.

Figure 43 - structure output of relief camp data.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 30


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Create Volunteer, Inserting data, and Structure output.

Figure 44 - Creating Volunteer database.

Figure 45 - Proof creating volunteer database.

Figure 46 - Inserting volunteer data.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 31


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Figure 47 - Proof inserting volunteer data.

Figure 48 – structure output of volunteer database.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 32


Men Sandasara UOW No: W2087738 / IIT No: 20221297

04.Ten SQL query scripts.


-- ten SQL queries --
1. *Types and Counts of Different Disaster Events:*
SELECT Type, COUNT(*) AS EventCount
FROM disaster_event
GROUP BY Type;

2. *Total Estimated Damage Cost of All Events:*


SELECT SUM(EstimatedDamageCost) AS TotalDamageCost
FROM disaster_event;.

3. *Most Severe Disaster Event:*SELECT Type, SeverityLevel, EstimatedDamageCost


FROM disaster_event
ORDER BY EstimatedDamageCost DESC
LIMIT 1;

4. *Donors and Their Contact Information:*


SELECT Name, ContactNo1, ContactNo2, ContactNo3, TypeOfDonation
FROM donor;

5. *Volunteers and Their Area of Expertise:*


SELECT Name, AreaExpertise
FROM volunteer;

6. *Relief Camps and Their Current Occupancy:*


SELECT Name, Location, Capacity, NumberOfPeopleAccommodated
FROM relief_camp;

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 33


Men Sandasara UOW No: W2087738 / IIT No: 20221297

7. *Natural Disasters with Predicted High Frequencies:*


SELECT EventID, MeteorologicalData, GeologicalData, PredictedFrequency
FROM natural_disasters
WHERE PredictedFrequency > 0;

8. *Disaster Management Programs and Their Duration:*


SELECT ProgramName, StartingDate, EndingDate
FROM disaster_management;

9. *Man-Made Disasters and Their Preventive Measures:*


SELECT Cause, ResponsibilityParties, PreventiveMeasure
FROM man_made_disasters;

10. *Query to Find Persons Volunteering and Their Assigned Relief Camps:*
SELECT p.Name AS VolunteerName, r.Name AS ReliefCamp
FROM person p
JOIN relief_camp r ON p.Name = r.PersonName;

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 34


Men Sandasara UOW No: W2087738 / IIT No: 20221297

05.Ten SQL queries and Output.

Query 01.

Figure 49 - Query 01 code.

Figure 50 - Query 01 Output.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 35


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Query 02.

Figure 51 - Query 02 code.

Figure 52 - Query 02 output.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 36


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Query 03.

Figure 53 - Query 03 code.

Figure 54 - Query 03 output.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 37


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Query 04.

Figure 55 - Query 04 code.

Figure 56 - Query 04 output.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 38


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Query 05.

Figure 57 - Query 05 code.

Figure 58 - Query 05 output.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 39


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Query 06.

Figure 59 - Code 06 code.

Figure 60 - Query 06 output.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 40


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Query 07.

Figure 61 - Query 07 code.

Figure 62 - Query 07 output.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 41


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Query 08.

Figure 63 - Query 08 code.

Figure 64 - Query 08 output.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 42


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Query 09.

Figure 65 - Query 09 code.

Figure 66 - Query 09 output.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 43


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Query 10.

Figure 67 - Query 10 code.

Figure 68 - Query 10 output.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 44


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Query Purpose Table involved SQL Correct


No Execution

Types and disaster_event SELECT Type, COUNT(*) AS Yes


Counts of EventCount<br>FROM
01
Different disaster_event<br>GROUP BY Type;
Disaster
Events.

Total disaster_event SELECT SUM(EstimatedDamageCost) AS Yes


Estimated TotalDamageCost<br>FROM
02
Damage Cost disaster_event;
of All Events.

Most Severe disaster_event SELECT Type, SeverityLevel, Yes


Disaster EstimatedDamageCost<br>FROM
03
Event. disaster_event<br>ORDER BY
EstimatedDamageCost DESC LIMIT 1;

Donors and donor SELECT Name, ContactNo1, ContactNo2, Yes


Their ContactNo3, TypeOfDonation<br>FROM
04
Contact donor;
Information.

Volunteers Volunteer SELECT Name, AreaExpertise<br>FROM Yes


and Their volunteer;
05
Area of
Expertise.

Relief Camps relief_camp SELECT Name, Location, Capacity, Yes


and Their NumberOfPeopleAccommodated<br>FROM
06
Current relief_camp;
Occupancy.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 45


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Natural natural_disasters SELECT EventID, MeteorologicalData, Yes


Disasters GeologicalData,
07
with PredictedFrequency<br>FROM
Predicted natural_disasters<br>WHERE
High PredictedFrequency > 0;
Frequencies.

Disaster disaster_management SELECT ProgramName, StartingDate, Yes


Management EndingDate<br>FROM
08
Programs disaster_management;
and Their
Duration.

Man-Made man_made_disasters SELECT Cause, ResponsibilityParties, Yes


Disasters and PreventiveMeasure<br>FROM
09
Their man_made_disasters;
Preventive
Measures.

Persons person, relief_camp SELECT p.Name AS VolunteerName, r.Name Yes


Volunteering AS ReliefCamp<br>FROM person p<br>JOIN
10
and Their relief_camp r ON p.Name = r.PersonName;
Assigned
Relief
Camps.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 46


Men Sandasara UOW No: W2087738 / IIT No: 20221297

Conclusion.
This page presents the Disaster Management System, which offers a complete framework for
handling and reacting to many types of disasters. by combining important organizations like
disaster events, disaster management, relief camps, volunteers, and donors. An effective
foundation for anticipatory disaster preparedness, response, and recovery is offered by the
disaster management system. utilizing technology and cross-organizational cooperation.

By providing prompt access to pertinent data, disaster response planning, resource allocation,
and general coordination activities, the SQL queries support efficient decision-making processes.
Through the utilization of these inquiries, interested parties can acquire a more profound
comprehension of the functions of the Disaster Management System and make knowledgeable
choices to lessen the consequences of calamities and assist impacted areas.

4BUIS015C.2 DATABASE DESIGN AND IMPLEMENTATION 47

You might also like