Professional Documents
Culture Documents
CT-21075 - DBMS - Assignment #2 PDF
CT-21075 - DBMS - Assignment #2 PDF
“ASSIGNMENT #2”
Generated SQL:
CREATE TABLE Patient
(
ID INT NOT NULL,
Name INT NOT NULL,
Address INT NOT NULL,
PRIMARY KEY (ID)
);
(
ID INT NOT NULL,
fk_Patient_ID INT NOT NULL,
Diagnosis_Type INT NOT NULL,
Diagnosis_Date INT NOT NULL,
ID INT NOT NULL,
ID INT NOT NULL,
PRIMARY KEY (ID),
FOREIGN KEY (ID) REFERENCES Patient(ID),
FOREIGN KEY (ID) REFERENCES Treatment(ID)
);
Logical ERD:
Referential Integrity:
The following referential integrity constraints will apply on the Hospital Management System:
• The Appointment table has a foreign key referencing the Patient table, which ensures that
a patient cannot have an appointment unless they exist in the Patient table.
• The Appointment table has a foreign key referencing the Doctor table, which ensures that
an appointment cannot be made with a doctor that does not exist in the Doctor table.
Pa ge 5|6
Database Management Systems (DBMS) Course Code: CT-261
• The Appointment table has a foreign key referencing the Department table, which
ensures that an appointment cannot be made in a department that does not exist in the
Department table.
• The Diagnosis table has a foreign key referencing the Patient table, which ensures that a
diagnosis cannot be associated with a patient that does not exist in the Patient table.
• The Prescription table has a foreign key referencing the Treatment table, which ensures
that a prescription cannot be associated with a treatment that does not exist in the
Treatment table.
• The Treatment table has a foreign key referencing the Diagnosis table, which ensures that
a treatment cannot be associated with a diagnosis that does not exist in the Diagnosis
table.
• The Ward table has a foreign key referencing the Department table, which ensures that a
ward cannot belong to a department that does not exist in the Department table.
• The Bed table has a foreign key referencing the Ward table, which ensures that a bed
cannot belong to a ward that does not exist in the Ward table.
• The Insurance table has a foreign key referencing the Patient table, which ensures that an
insurance policy cannot be associated with a patient that does not exist in the Patient
table.
• The Payment table has a foreign key referencing the Treatment table, which ensures that
a payment cannot be associated with a treatment that does not exist in the Treatment
table.
Pa ge 6|6