Consider a relation that depicts a tutorial room booking in a university. Each faculty assigns a person to handle the booking for all tutorial classes for that faculty. The person’s email address is given to the university’s booking system as a contact person. BOOKING(b_date, b_starttime, b_endtime, unit_code, contact_person, room_no, tutor_id).
Exercise: Identify candidate key(s) and primary key for the relation if the following business rules are applicable:
1) Tutorial classes can be either 1 hour or 2 hours long.
2) A tutor can only teach one tutorial class in a given unit.
3) There are no parallel sessions of tutorial classes.
My answer: 1 of candidate key is (tutor_id, d_date). My suggestion key can make each tuple unique BUT there is no constraint that prevents users input incorrectly as below:
tutor_id | d_date | b_starttime | b_endtime | unit_code |
AAAA | Mon | 6 PM | 8PM | FIT1111 |
BBBB | Mon | 6 PM | 7PM | FIT1111 |
OR
tutor_id | d_date | b_starttime | b_endtime | unit_code |
AAAA | Mon | 6 PM | 8PM | FIT1111 |
BBBB | Mon | 7 PM | 8PM | FIT1111 |
Consequently, my key does not meet the business rule no.3. Then, I add 2 more attributes to candidate key (tutor_id, d_date, b_starttime, b_endtime).
My questions is when we choose candidate key, apart from guaranteeing the uniqueness of each tuple, do we need to prevent users from possibly wrong input which may break the business rules? If yes, when we set, for example, 4 attributes (A, B, C, D) as the primary key, whether the DBMS blocks users from wrong input action as in the table above?
Thanks.