While designing tables how one-to-many relationship is implemented?
ERD, consists of entities and their relationships. You learnt through lectures that we do not want to draw many:many relationships in our ERD. We want to split up by putting an associative in between. we then obtain two 1:many relationships with the associative entity in the middle. Lets see how to resolve such kind of relationship into I to many and implement it by using tabular form.
Examples:
1. Learner - lecturer. A learner will have one or more lecturer. The same lecturer will have masses of students.
This many:many is not allowed, we will change this to add a associative-entity in the central point.
The three entities could translate into the following three tables:
Learner Table | Learner lecturer Table | lecturer Table |
Learner Number first name Address residenceTelNumber | Learner Number lecturer Number | lecturer Number first name OfficeNumber jobTelNumber |
In the student table, the Learner Number will be the primary key.
In the lecturer table, the lecturer Number will be the primary key.
In the junction table - Learner lecturer, the Learner Number and the lecturer Number are both foreign keys. As a combination they will form the primary key.
The information in the tables could look as follows:
Learner Table:
Learner Number | Name | Address | HomeTelNumber |
S00001 | A de Wet | 555-5595 | |
S00008 | M Steep | 88 | 555-1123 |
lecturer Table:
lecturer Number | Name | OfficeNumber | WorkTelNumber |
P00001 | A Einstein | A101 | 555-1010 |
P00002 | I | A201 | 555-1020 |
0 Comments
Please add nice comments or answer ....