0% found this document useful (0 votes)
14 views14 pages

DBMS ER2RelSchema

The document outlines the steps for mapping various entity types and relationships in a database from an Entity-Relationship (ER) model to a relational model. It details the processes for regular entities, weak entities, binary relationships (1:1, 1:N, M:N), multivalued attributes, and N-ary relationships, specifying how to create relations, define primary keys, and establish foreign keys. Additionally, it provides examples and approaches for implementing these mappings effectively.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views14 pages

DBMS ER2RelSchema

The document outlines the steps for mapping various entity types and relationships in a database from an Entity-Relationship (ER) model to a relational model. It details the processes for regular entities, weak entities, binary relationships (1:1, 1:N, M:N), multivalued attributes, and N-ary relationships, specifying how to create relations, define primary keys, and establish foreign keys. Additionally, it provides examples and approaches for implementing these mappings effectively.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Step 1.

Mapping Regular Entity Types


• For each regular (strong) entity type E, create a relation R that includes all the
simple attributes of E
• Include only the simple component attributes of a composite attribute
• Choose one of the key attributes of E as the primary key for R
• If the chosen key of E is a composite, then the set of simple attributes that form it will
together form the primary key of R
• We create the relations EMPLOYEE, DEPARTMENT, and PROJECT
• We choose Ssn, Dnumber, and Pnumber as primary keys for the relations
EMPLOYEE, DEPARTMENT, and PROJECT respectively
Step 2. Mapping Weak Entity Types
• For each weak entity type W with owner entity type E, create a relation R and
include all simple attributes (or simple components of composite attributes)
• In addition, include as foreign key attributes, the primary key attribute(s) of
the relation(s) that correspond to the owner entity type(s)
• The primary key of R is the combination of the primary key(s) of the
owner(s) and the partial key of the weak entity type W
• We create the relation DEPENDENT in this step (Ssn renamed as Essn)
• The primary key of the DEPENDENT relation is the combination {Essn,
Dependent_name}
Step 3: Mapping of Binary 1:1 Relationship Types
• There are three possible approaches:
1. The foreign key approach,
2. The merged relationship approach,
3. The cross-reference or relationship relation approach
• The first approach is the most useful and should be followed unless special
conditions exist
1. The foreign key approach
1. For each binary 1:1 relationship type R, identify the relations S and T that
correspond to the entity types participating in R
Step 3: Mapping of Binary 1:1 Relationship Types..
1. The foreign key approach…
2. Choose one of the relations (say, S) and include the primary key of T as a
foreign key in S
• It is better to choose an entity type with total participation in R as S (Otherwise
may have a lot of NULL values for the foreign key attribute)
3. Include all the simple attributes (or simple components of composite
attributes) of the 1:1 relationship type R as attributes of S
• Eg. Consider the relation MANAGES

Foreign key referencing


EMPLOYEE table
Step 3: Mapping of Binary 1:1 Relationship Types
2. The merged relation approach
• Merge the two entity types and the relationship type into a single relation
• This is preferrable when both participations are total
• In this case, the two tables will have exactly the same number of tuples at all times
Step 3: Mapping of Binary 1:1 Relationship Types..
3. The Cross-reference or relationship relation approach
• Set up a third relation R for the purpose of cross-referencing the primary keys
of the two relations S and T representing the entity types (as done for binary
M:N relationships)
• The relation R will include the primary key attributes of S and T as
foreign keys to S and T, and the attributes of R, if any
• The primary key of R will be one of the two foreign keys
• The drawback is having an extra relation, and requiring extra join operations
when combining related tuples from the tables.
Step 4: Mapping of Binary 1:N Relationship Types
1. The Foreign key approach
• For each regular binary 1:N relationship type R, identify the relation S that
represents the participating entity type at the N-side of the relationship type
• Include the primary key of the relation T that represents the other entity type,
as foreign key in S
• Include any simple attributes (or simple components of composite attributes)
of the 1:N relationship type as attributes of S
Step 4: Mapping of Binary 1:N Relationship Types..
2. The relationship relation approach
• We create a separate relation R whose attributes are the primary keys of S and
T, which will also be foreign keys to S and T
• The primary key of R is the same as the primary key of S (N-side table)
Step 5: Mapping of Binary M:N Relationship Types
The relationship relation approach
• The only option for M:N relationships, in relational model with no
multivalued attributes
• For each binary M:N relationship type R, create a new relation S
• Include the primary keys of the relations that represent the participating
entity types as foreign key attributes in S
• The primary key of S is the combination of the above primary keys
• Also include any simple attributes of the M:N relationship type (or simple
components of composite attributes) as attributes of S
Step 6: Mapping of Multivalued Attributes
• For each multivalued attribute A, create a new relation R
• R shall include
• An attribute corresponding to A
• The primary key attribute(s) K of the relation corresponding to the entity type or
relationship type that has A as a multivalued attribute; This will act a as a foreign key
in R
• A and K together forms the primary key of R

Foreign key referencing


DEPARTMENT table
Step 7: Mapping of N-ary Relationship Types
• We use the relationship relation option
• Create a new relationship relation S to represent the relationship type R
• Include the primary keys of the relations that represent the participating
entity types, as foreign key attributes in S
• Also include any simple attributes of the n-ary relationship type (or simple
components of composite attributes) as attributes of S
• The primary key of S is usually a combination of all the foreign keys that
reference the relations representing the participating entity types
• However, if the cardinality constraints on any of the entity types E
participating in R is 1, then the primary key of S should not include the
foreign key attribute that references the relation E′ corresponding to E
Step 7: Mapping of N-ary Relationship Types…
Correspondence between ER and Relational Models
ER Diagram for
the COMPANY
Database

You might also like