preps | erm | entities | relationships | sql
Class Schedule
This work
is licensed under a
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
home & schedule | syllabus | contact | grades
Use a copy of the Primary Key from the one side of a relationship
as a Foreign Key in the many side of a relationship.
A relationship requires the primary key of one entity class be inserted as a foreign key in a second entity class.
The image is a screenshot from the MS Access database tool (which we will not be using), but it describes the essence of good relationships).
In a one-to-one relationship, each record in Entity Class A can have only one matching record in Entity Class B, and each record in Entity Class B can have only one matching record in Entity Class A.
in a one-to-many relationship, a record in Entity Class A can have many matching records in Entity Class B, but a record in Entity Class B has only one matching record in Entity Class A
note that your Entity Class properties provide you advice about how to ensure the relationships are based on the proper field properties.
in a many-to-many relationship, a record in Entity Class A can have many matching records in Entity Class B, and a record in Entity Class B can have many matching records in Entity Class A
05 November lecture | preps | erm | entities | relationships | sql