0% found this document useful (0 votes)
5 views

Lecture 6 ER - Relational Mapping

The document outlines the process of converting an Entity-Relationship (ER) model into a relational database schema. It details the steps for mapping entity types, relationships, and attributes into relations, including considerations for primary and foreign keys. The document also explains the concepts of cardinality and modularity in the context of database tables.

Uploaded by

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

Lecture 6 ER - Relational Mapping

The document outlines the process of converting an Entity-Relationship (ER) model into a relational database schema. It details the steps for mapping entity types, relationships, and attributes into relations, including considerations for primary and foreign keys. The document also explains the concepts of cardinality and modularity in the context of database tables.

Uploaded by

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

ER-Relational Mapping

Lecture 5
Requirements
• Special handout
ER to Relational Mapping
• This refers to the creation of the database
schema
What is a Relation?
• A relation is a table that holds the data we are
interested in. It is two-dimensional and has
rows and columns.
• Each entity type in the ER model is mapped
into a relation.
– The attributes become the columns.
– The individual entities become the rows.
• Relations can be represented textually as:
tablename(primary key, attribute 1, attribute
2, ... , foreign key)

• If matric_no was the primary key, and there


were no foreign keys, then the table above
could be represented as:
student(matric no, name, address,
date_of_birth)
• When referring to relations or tables,
cardinality is considered to be the
number of rows in the relation or
table, and modularity is the number
of columns in a table or attributes in
a relation.
Steps
• STEP 1: For regular entity type E in ER
schema, create a relation R that
includes all the simple attributes, and
component attributes of composite
attributes.
– Select the primary key.
• STEP 2: For weak entity type W in ER
schema, with owner entity type E, create a
relation R, include all simple attributes (or
component attributes of composite
attributes) of W as attributes of R.
• In addition, include the primary key
attributes of the relation Q for the owner
entity type E.
• Primary key is the combination of primary
key of Q and partial key of R.
• STEP 3: For 1:1 relationship X,
suppose S and T are the relations for
the entity types participating in it.
• Include primary key of T as foreign
key of S.
• Include other attributes of the
relationship X as attributes of S.
• STEP 4: For 1:N relationship Y,
suppose S relation corresponds to
the entity type at the N-side, and T
relation corresponds to the entity
type at the other side.
• Include primary key of T as foreign
key of S.
• STEP 5: For M:N relationship Z, create a new
relation R to represent Z.
• Include simple attributes of Z in R.
• Include the primary keys of S and T as foreign
keys of R, their combination forms the
primary key of R.
• STEP 6: For multivalued attribute A,
create a new relation R that includes an
attribute corresponding to A.
• Include primary key of the relation of
the entity type having A as an attribute.
Primary key is their combination.
• STEP 7: For n-ary relationship type X, and
n>2, create a new relation R.

• Include primary key of each participating


entity type's relation as foreign key of R.

• Include attributes of X as simple attributes


of R.

You might also like