SQL Assignment 1
SQL Assignment 1
DATABASE
YOGESHWAR
22-UCC-042
SCENARIO DESCRIPTION
Disaster Relief Database –
In recent years, natural disasters like floods, earthquakes, and cyclones have affected
several regions, displacing families and causing severe damage to life and property. To
manage the relief efforts efficiently, the government and non-governmental organizations
(NGOs) have come together to create a Disaster Relief Management System.
This system is responsible for tracking:
● Individuals affected by disasters.
● Types of disasters and their locations.
● Relief aid distributed, including food, water, shelter, and medical assistance.
● Amount of aid provided to each individual.
Affected Individuals
Each individual affected by a disaster is recorded in the system with personal details like
name, age, and gender. An individual may be affected by more than one disaster and may
receive multiple types of aid.
Disaster Events
Each disaster is recorded with a unique ID, type (e.g., flood, earthquake), the location it
occurred, and the date. This allows the system to track which regions were affected and
what kind of aid they required.
Types of Aid
Aid is categorized into several types:
● Food
● Water
● Shelter
● Medical
Each aid type is uniquely identified and can be distributed to any affected individual
depending on their need and the severity of the disaster.
Aid Distribution
Every time aid is distributed, the system logs:
● The individual who received the aid
● The disaster related to that aid
● The type of aid provided
● The amount of aid (in units or value)
This ensures transparency, helps avoid duplication, and allows decision-makers to identify
gaps in relief efforts.
2. Normalization
First Normal Form (1NF)
Remove repeating groups. Create one row per aid type and amount.
Table Name: DisasterRelief_1NF
A
ReliefI DisasterTy Locati IndividualNa Gend AidTy AidAmou
Date g
D pe on me er pe nt
e
2025- 3
1 Flood City A Alice Thomas F Food 100
03-01 4
2025- 3
1 Flood City A Alice Thomas F Water 50
03-01 4
2025- 3 Shelte
1 Flood City A Alice Thomas F 300
03-01 4 r
... ... ... ... ... ... ... ... ...
(Continued for all 10 records.)
CODES
create database D1;
drop database d1;
use d1;
Table Creation;
-- Data Insertion
-- Aid Types
INSERT INTO AidTypes VALUES
('T1', 'Food'),
('T2', 'Water'),
('T3', 'Shelter'),
('T4', 'Medical');
-- Disasters
INSERT INTO Disasters VALUES
('D1', 'Flood', 'City A', '2025-03-01'),
('D2', 'Earthquake', 'City B', '2025-03-05'),
('D3', 'Cyclone', 'City C', '2025-03-10'),
('D4', 'Flood', 'City D', '2025-03-12');
-- Individuals
INSERT INTO Individuals VALUES
('IND1', 'Alice Thomas', 34, 'F'),
('IND2', 'Ramesh Kumar', 45, 'M'),
('IND3', 'Meena Patel', 29, 'F'),
('IND4', 'John Roy', 50, 'M'),
('IND5', 'Anita Joseph', 41, 'F'),
('IND6', 'Suresh Pillai', 36, 'M'),
('IND7', 'Kiran Dev', 25, 'M'),
('IND8', 'Farah Sheikh', 38, 'F'),
('IND9', 'Asha Menon', 31, 'F'),
('IND10', 'Sanjay Rao', 47, 'M');
-- Aid Distribution
INSERT INTO AidDistribution VALUES
('A1', 'IND1', 'D1', 'T1', 100),
('A2', 'IND1', 'D1', 'T2', 50),
('A3', 'IND1', 'D1', 'T3', 300),
('A4', 'IND2', 'D2', 'T4', 500),
('A5', 'IND2', 'D2', 'T2', 50),
('A6', 'IND3', 'D1', 'T1', 100),
('A7', 'IND3', 'D1', 'T3', 300),
('A8', 'IND4', 'D3', 'T2', 50),
('A9', 'IND4', 'D3', 'T1', 100),
('A10', 'IND5', 'D4', 'T1', 100),
('A11', 'IND5', 'D4', 'T3', 300),
('A12', 'IND5', 'D4', 'T4', 500),
('A13', 'IND6', 'D2', 'T4', 500),
('A14', 'IND7', 'D3', 'T2', 50),
('A15', 'IND8', 'D1', 'T1', 100),
('A16', 'IND8', 'D1', 'T2', 50),
('A17', 'IND9', 'D3', 'T3', 300),
('A18', 'IND9', 'D3', 'T4', 500),
('A19', 'IND10', 'D2', 'T2', 50),
('A20', 'IND10', 'D2', 'T1', 100),
('A21', 'IND10', 'D2', 'T3', 300);
-- Queries
-- 1. Individuals who received Medical aid
SELECT i.Name, a.AidAmount
FROM Individuals i
JOIN AidDistribution ad ON i.IndividualID = ad.IndividualID
JOIN AidTypes a ON ad.AidTypeID = a.AidTypeID
WHERE a.AidType = 'Medical';
OUTPUT: