0% found this document useful (0 votes)
135 views9 pages

ER

The document describes an ER diagram for a hospital database with 3 entities: Patient, Doctor, and Tests. It lists the primary keys for each entity - ID for Patient and Doctor, and Name for Tests. It also notes that Age is a derived attribute for the Patient entity.

Uploaded by

Mansi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
135 views9 pages

ER

The document describes an ER diagram for a hospital database with 3 entities: Patient, Doctor, and Tests. It lists the primary keys for each entity - ID for Patient and Doctor, and Name for Tests. It also notes that Age is a derived attribute for the Patient entity.

Uploaded by

Mansi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

 

ER Diagram for Hospital:

● It has three entities: Patient, Doctor and Tests.


● Age is a derived attribute for Patient Entity
● Name in the Tests entity is a Primary Key
● ID in the Doctor entity is a Primary Key
● ID in the Patient entity is a Primary Key
E-R Diagram of Railway reservation System
E-R Diagram into Tables
Step 1: E-R Diagram

Step 2: Converting the E-R Diagram into Tables


a. Converting entity to table and attribute to columns
USER

U_id Primary Key


Password  

Security_quest  

Passenger

PNR Primary Key

P_name  

Age  

Gender  

Seat_no.  

Reserve_status  

U_id Foreign key references to U_id of User table.

Status_id Foreign key references to Status_id of Train_Status Table.


Train_id Foreign key references to Train_id of Train Table

Train_Status

Status_id Primary Key

Wait_seat  

Avail_seat  

Booked_seat  

Train_id Foreign key references to Train_id of Train Table

PNR Foreign key references to PNR of Passenger table.

Train

Train_id Primary Key

T_name  

Train_type  
Avail_class  

Status_id Foreign key references to Status_id of Train_Status Table.

Route

Arr_time  

Depart_time  

Stop no.  

Station_id Foreign key references to Station_id of Station table.

Train_id Foreign key references to Train_id of Train Table

Station

Station_id Primary Key

Station_name  
Step 3: Mapping of Attributes
a. Simple Attributes
Simple attributes which cannot be divided into subparts.
Example: Seat Number of passenger
b. Composite Attributes
Composite attributes which can be divided into subparts.
Example: Passenger Name, Reservation status
P_name

First_Name

Middle_Name

Last_name

Reserve_status

Waiting

Confirmed

Step 4: Mapping of entity set


a. Weak entity set
For each weak entity type with owner entity, create a table and include all simple
attributes of weak entity type as columns of table, including foreign key attributes as
the primary key of the table that correspond to the owner entity type.(Owner entity is
strong entity having own primary key.)
Example: Route (Weak Entity) in Train (Owner entity).

Step 5: Mapping of Relationships


a. Foreign Key approach
Passenger_Table

U_id Passenger table makes foreign key references to U_id of User table.

Status_id Passenger table makes foreign key references to Status_id of Train_Status Table.

Train_id Passenger table makes foreign key references to Train_id of Train Table

Train_Status

Train_id Train_status table makes foreign key references to Train_id of Train Table

PNR Train_status table makes foreign key references to PNR of Passenger table.

Train

Route
Station_id Route table makes foreign key references to Station_id of Station table.

Train_id Route table makes foreign key references to Train_id of Train Table

You might also like