Friday, March 23, 2018

Logical example

As the example shows, a connecting table is added and the many to many relationship is removed. This model allows many students to be related to many courses and vice versa without the existence of an actual many to many relationship.

Class Reflection Transforming Conceptual to Logical
Many to Many Relationships
Many to many relationships do not exist in a database, so there must be a way to model that sort of relationship. Many to many can exist in a conceptual model but you have to remove direct many to many relationships in a logical model. An example of how this might work is a many to many relationship between student and course.
Many students can be part of many courses and many courses can have many students.
What you would do is add a table in between the two tables called StudentCourse. It will contain the courseID and Student ID and additional info as required. The 2 tables will each have a one to many relationship to the StudentCourse table
Conceptual example
Logical example
As the example shows, a connecting table is added and the many to many relationship is removed. This model allows many students to be related to many courses and vice versa without the existence of an actual many to many relationship.
One to One
When transforming to logical, in a one to one relationship, the ID from the either side of the relationship gets added as a new column to the other side of the relationship as a foreign key.
One to Many
When transforming to logical, in a one to many relationship, the ID from the One side of the relationship gets added as a new column to the Many side of the relationship as a foreign key.
Superclass subclass relationships
Create one relation for the super type that holds all the common attributes for the subtypes.
Or create one relation for each subtype.
Comments
Post a Comment