CS331 - Normalization Exercise - Solution
CS331 - Normalization Exercise - Solution
Appointment
StaffNo DentistName PatientNo PatientName SurgeryNo
Date Time
S1011 Tony Smith P100 Gillian White 12-Aug-03 10.00 S10
S1011 Tony Smith P105 Jill Bell 13-Aug-03 12.00 S15
S1024 Helen Pearson P108 Ian MacKay 12-Sept-03 10.00 S10
S1024 Helen Pearson P108 Ian MacKay 14-Sept-03 10.00 S10
S1032 Robin Plevin P105 Jill Bell 14-Oct-03 16.30 S15
S1032 Robin Plevin P110 John Walker 15-Oct-03 18.00 S13
Candidate primary keys
➢ StaffNo: not possible since the same dentist occurs in multiple rows since he
can treat several patients
➢ PatientNo: not possible since a patient may have more than one
appointment
➢ (StaffNo, PatientNo): not possible since a patient may have more than one
appointment with the same doctor
➢ (PatientNo, appointment): not possible since a patient can make more than
appointment at the same date and time with multiple doctors but finally he
comes to only one
➢ (StaffNo, Appointment): the most suitable one (unique)
2
Question 1: insertion anomalies
Appointment
StaffNo DentistName PatientNo PatientName SurgeryNo
Date Time
S1011 Tony Smith P100 Gillian White 12-Aug-03 10.00 S10
3
Question 1: Delete anomalies
Appointment
StaffNo DentistName PatientNo PatientName SurgeryNo
Date Time
S1011 Tony Smith P100 Gillian White 12-Aug-03 10.00 S10
4
Question 1: Modification anomalies
Appointment
StaffNo DentistName PatientNo PatientName SurgeryNo
Date Time
S1011 Tony Smith P100 Gillian White 12-Aug-03 10.00 S10
5
First Normal Form
Appointment → data type
• Date YYYY-MM-DD
• Small date time YYYY-MM-DD hh:mm:ss
• Date time YYYY-MM-DD hh:mm:ss[nnn]
• ……
✓ No multi-valued attributes
✓ Records are uniquely identified
Second Normal Form
3 independent partial dependencies
PatientNo PatientName
✓ No multi-valued attributes
Borrower_id → name
since every borrower is identified with an unique id
Borrower_id → address
since each borrower has generally only one address
No transitive dependency
BCNF