1/15
Looks like no tags are added yet.
Transforming an ERD
The process of converting entities into tables, attributes into fields, and key attributes into primary keys.
ERD to Table: Entity
Transform each entity into a database table.
ERD to Table: Attribute
Transform each attribute into a field or column.
ERD to Table: Key Attribute
Transform the key attribute into the table's primary key.
Converting a 1:1 Relationship
Merge the two entities into one table. One entity becomes an attribute of the other.
Converting a 1:N Relationship
Add the primary key from the ONE entity as a foreign key in the MANY entity.
Converting a N:M Relationship
Create an intersection table containing the primary keys from both original tables as foreign keys.
Foreign Key Placement in 1:N
The primary key from the ONE side goes into the MANY side as a foreign key.
Intersection Table Step 1
Add an intersection table between the two original tables.
Intersection Table Step 2
Flip the relationship lines so the MANY side faces the intersection table.
Intersection Table Step 3
Add the primary keys from both original tables as foreign key fields in the intersection table.
Intersection Table Step 4
Give the intersection table a name. Example: Registration.
Intersection Table Step 5
Add other relevant fields if necessary. Example: Grade.
Student and Course Example
Students and Courses have a many-to-many relationship, so create a Registration table containing Student ID, Course ID, and Grade.
Student and ID Card Example
Student and ID Card have a one-to-one relationship, so merge the entities into one table.
Student and Library Book Example
Student and Library Book have a one-to-many relationship, so place the Student primary key in the Library Book table as a foreign key.