Question: Create an ER Diagram based off this code: - - Create the database CREATE DATABASE HospitalDB; USE HospitalDB; - - Create the Patient table CREATE

Create an ER Diagram based off this code:
-- Create the database
CREATE DATABASE HospitalDB;
USE HospitalDB;
-- Create the Patient table
CREATE TABLE Patient (
PatientID INT AUTO_INCREMENT PRIMARY KEY,
Name VARCHAR(100) NOT NULL,
ContactInfo VARCHAR(150),
Address VARCHAR(255),
Age INT,
Weight DECIMAL(5,2),
Height DECIMAL(5,2),
InsuranceInfo VARCHAR(150),
SSN VARCHAR(11) UNIQUE
);
-- Create the Doctor table
CREATE TABLE Doctor (
DoctorID INT AUTO_INCREMENT PRIMARY KEY,
Name VARCHAR(100) NOT NULL,
Specialization VARCHAR(100),
ContactInfo VARCHAR(150)
);
-- Create the Room table
CREATE TABLE Room (
RoomNumber INT PRIMARY KEY,
RoomType VARCHAR(50),
Availability BOOLEAN
);
-- Create the Staff table
CREATE TABLE Staff (
StaffID INT AUTO_INCREMENT PRIMARY KEY,
Name VARCHAR(100) NOT NULL,
Role VARCHAR(100),
ContactInfo VARCHAR(150)
);
-- Create the Treatment table
CREATE TABLE Treatment (
TreatmentID INT AUTO_INCREMENT PRIMARY KEY,
TreatmentDetails TEXT,
Date DATE,
StaffID INT,
PatientID INT,
FOREIGN KEY (StaffID) REFERENCES Staff(StaffID),
FOREIGN KEY (PatientID) REFERENCES Patient(PatientID)
);
-- Create the Patient_Doctor table for the many-to-many relationship
CREATE TABLE Patient_Doctor (
PatientID INT,
DoctorID INT,
PRIMARY KEY (PatientID, DoctorID),
FOREIGN KEY (PatientID) REFERENCES Patient(PatientID),
FOREIGN KEY (DoctorID) REFERENCES Doctor(DoctorID)
);
-- Create the Patient_Room table for the one-to-one relationship
CREATE TABLE Patient_Room (
PatientID INT,
RoomNumber INT,
AdmissionDate DATE,
DischargeDate DATE,
PRIMARY KEY (PatientID, RoomNumber),
FOREIGN KEY (PatientID) REFERENCES Patient(PatientID),
FOREIGN KEY (RoomNumber) REFERENCES Room(RoomNumber)
);
-- Create the Patient_Treatment table for the one-to-many relationship
CREATE TABLE Patient_Treatment (
PatientID INT,
TreatmentID INT,
PRIMARY KEY (PatientID, TreatmentID),
FOREIGN KEY (PatientID) REFERENCES Patient(PatientID),
FOREIGN KEY (TreatmentID) REFERENCES Treatment(TreatmentID)
);
-- Create the Staff_Treatment table for the one-to-many relationship
CREATE TABLE Staff_Treatment (
StaffID INT,
TreatmentID INT,
PRIMARY KEY (StaffID, TreatmentID),
FOREIGN KEY (StaffID) REFERENCES Staff(StaffID),
FOREIGN KEY (TreatmentID) REFERENCES Treatment(TreatmentID)
);
Use entites with the bubbles and lines.
 Create an ER Diagram based off this code: -- Create the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!