14-02-2013, 11:05 AM
How to translate ER Model to Relational Model
How to translate.ppt (Size: 140 KB / Downloads: 217)
From ER Model to Relational Model
So… how do we convert an ER diagram into a table? Simple!!
Basic Ideas:
Build a table for each entity set
Build a table for each relationship set if necessary (more on this later)
Make a column in the table for each attribute in the entity set
Indivisibility Rule and Ordering Rule
Primary Key
Representation of Weak Entity Set
Weak Entity Set Cannot exists alone
To build a table/schema for weak entity set
Construct a table with one column for each attribute in the weak entity set
Remember to include discriminator
Augment one extra column on the right side of the table, put in there the primary key of the Strong Entity Set (the entity set that the weak entity set is depending on)
Primary Key of the weak entity set = Discriminator + foreign key
Representing Relationship SetUnary/Binary Relationship
For one-to-one relationship w/out total participation
Build a table with two columns, one column for each participating entity set’s primary key. Add successive columns, one for each descriptive attributes of the relationship set (if any).
For one-to-one relationship with one entity set having total participation
Augment one extra column on the right side of the table of the entity set with total participation, put in there the primary key of the entity set without complete participation as per to the relationship.
Representing Relationship SetIdentifying Relationship
This is what you have to know
You DON’T have to build a table/schema for the identifying relationship set once you have built a table/schema for the corresponding weak entity set
Reason:
A special case of one-to-many with total participation
Reduce Redundancy
Representing Class Hierarchy
Two general approaches depending on disjointness and completeness
For non-disjoint and/or non-complete class hierarchy:
create a table for each super class entity set according to normal entity set translation method.
Create a table for each subclass entity set with a column for each of the attributes of that entity set plus one for each attributes of the primary key of the super class entity set
This primary key from super class entity set is also used as the primary key for this new table