Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

1

Department of Computer Science


Bahria University, Islamabad

Fall 2020
BS-IT-4AB

Course Code : CSL-220


Database Management Systems

Lab Manual 11

Student Name: ____JAVERIA ABBASI_______________

Enrollment Number: _01-235191-014_________


2

Lab # 11
• Conversion from Entity Relationship Model to a Relational Model
___________________________________________________________________________
______________

This lab will focus on the process of converting a conceptual design in the form of an
ERD to a relational design i.e. schema. The process is carried out using a 9 step
algorithm, which specifies the conversion.

The 9 step algorithm of mapping conceptual to relational schema includes 7 steps for
mapping ER model to relations and the additional two steps are used to map the
additional concepts i.e. the EER to relational design. Various steps of the algorithm
include:
▪ Step 1: Mapping of Regular Entity Types
▪ Step 2: Mapping of Weak Entity Types
▪ Step 3: Mapping of Binary 1:1 Relationship Types
▪ Step 4: Mapping of Binary 1:N Relationship Types
▪ Step 5: Mapping of Binary M:N Relationship Types
▪ Step 6: Mapping of Multivalued Attributes
▪ Step 7: Mapping of N-ary Relationship Types
▪ Step 8: Options for Mapping Specialization or Generalization
▪ Step 9: Mapping of Union Types

Example
Carefully study the following ER Model before moving to the next page
3

Above figure can be represented as a Relational Model using following relations.

Company (CompanyID, name, address)


Staff (StaffID, dob, name, address, since, CompanyID)
Child (ChildID, name, StaffID )
Spouse (SpouseID, name, StaffID)
Phone (PhoneID, phoneNumber, StaffID)
Task (TaskID, description)
Perform (PerformID, StaffID, TaskID )
* Refer to lecture slides and book for details on each step of the algorithm.
* Refer to previous labs for Data Definition Language (DDL) syntax.

Lab Tasks
1. Convert ERD for US Congressperson into a relational model. Show relational
model as well as give DDL commands
4

CONGRESSPERSON:
NAME DISTRICT PARTY START_DATE

STATE:
name REGION NAME

BILL:
BILL_NAME PASSED_FAILED DATE_OF_VOTE

SPONSORED:
NAME BILL_NAME

VOTED:
HOW NAME BILL_NAME

Additional Practice:

Convert the ER Model of your project into Relational Model.

create table CONGRESSPERSON


(
Name varchar(50),
District varchar (50),
Party varchar (50),
Start_Date varchar (20)
);
alter table CONGRESSPERSON add constraint primary primary key (Name);

create table state


(
5

State_Name varchar (50),


region varchar (50),
name varchar (64),
foreign key (Name) references CONGRESSPERSON(name)
);

create table Bill


(
bill_name varchar (50),
passed_failed varchar (20),
date_of_vote varchar (20)
);
alter table bill add primary key(bill_name);

You might also like