DBMS3 4
DBMS3 4
GROUP MEMBERS:
1|Pag
e
1NF (First Normal Form):
To bring the tables into 1NF, we need to ensure that each attribute holds atomic values.
Since our tables are already atomic, no further modifications are required.
To address the 2NF errors, we'll create separate tables for the attributes causing partial
dependencies.
Additional Tables:
Staff_Salary:
Staff_Salary (Staff_id [FK], Salary)
Final Tables:
Staff:
Staff (Staff_id [PK], Name, Email, Phone_number, Role, Department, Address)
Administration:
Administration (Admin_id [PK], Name, Email, Phone_number, Position, Department, Address)
Disaster Report:
Disaster_Report (Report_id [PK], Disaster_type, Location, Report_date, Description,
Report_status)
Donation:
Donation (Donation_id [PK], Donor_name, Donor_email, Donor_phone, Donation_type,
Donation_amount, Donation_date, Donation_method)
Volunteer:
Volunteer (Volunteer_id [PK], Name, Email, Phone_number, Availability, Skills, Address)
Staff_Salary:
Staff_Salary (Staff_id [PK, FK], Salary)
.
Staff:
Staff (Staff_id [PK], Name, Email, Phone_number, Role, Department, Address)
Administration:
Administration (Admin_id [PK], Name, Email, Phone_number, Position, Department, Address)
2|Pag
e
Disaster Report:
Disaster_Report (Report_id [PK], Disaster_type, Location, Report_date, Description,
Reporter_name, Reporter_contact)
Donation:
Donation (Donation_id [PK], Donor_name, Donor_email, Donor_phone, Donation_type,
Donation_amount, Donation_date, Donation_method)
Volunteer:
Volunteer (Volunteer_id [PK], Name, Email, Phone_number, Availability, Skills, Address)
System Log:
System_Log (Log_id [PK], Timestamp, Action, User_id, Description)
3|Pag
e
CREATE TABLE Donation (
Donation_id SERIAL PRIMARY KEY,
Donor_name VARCHAR(100),
Donor_email VARCHAR(100),
Donor_phone VARCHAR(20),
Donation_type VARCHAR(100),
Donation_amount DECIMAL(10, 2),
Donation_date DATE,
Donation_method VARCHAR(100)
);
ADDING DATA
INSERT INTO Staff (Name, Email, Phone_number, Role, Department, Address)
VALUES ('John Doe', 'john@example.com', '1234567890', 'Manager', 'HR', '123 Main St');
4|Pag
e
Basic CRUD Operations
SELECT * FROM Staff;
SELECT s.Name, ss.Salary FROM Staff s INNER JOIN Staff_Salary ss ON s.Staff_id = ss.Staff_id;
Updating Data
UPDATE Staff SET Email = 'newemail@example.com' WHERE Staff_id = 1;
Delete Data
DELETE FROM Volunteer WHERE Volunteer_id = 1;
5|Pag
e