I have decomposed a relationship that tracks employee's and the hours they have spent working at hotels. The original relationship is as follows
R(national insurance number, contract Number, hours, eName, hotel Number, hotel Location)
rewritten as
R(A, B, C, D, E, F)
I have found the Functional dependencies
F:(A->D, E->F, AB->C, B->E, BA->E)
From this I have created the following 3 tables
1.
Employees:
national insurance number(A)
eName(D)
PRIMARY KEY(A)
2.
Works at:
contract Number(B)
Hours(C)
national insurance number(A)
PRIMARY KEY(B, AND A)
3.
Hotel:
contract Number(B)
hotel Number(E)
hotel Location(F)
PRIMARY KEY(B)
In my third table, I have a primary key that can determine both the number, and location of the hotel. But the hotel number can also determine the hotel location. Should I move the hotel location to a new table, with only hotel number? That would use more space, but is it necessary to reach the 3RD normal form?
When assuming that the FDs you derived are correct and complete, to achieve 3rd normal form in your setting, it is in deed necessary to split
Hotel(B,E,F) { B->E, E->F }intoHotelContract(B,E) { B->E }andHotel(E,F) { E->F }. Formally, in{ B->E, E->F },Bis the (sole) key,Eis a "non prime" attribute (i.e. is not part of any key), and thereforeFdepends transitively through a non prime attribute from a key. This violates 3rd normal form.With a schema
Hotel(B,E,F) { B->E, E->F }, which violates 3NF, you get a "deletion anomaly", i.e. you loose more information than necessary when deleting a tuple fromHotel. Suppose the following extension ofHotel:When you delete tuple
(b2,e2,f2), then you loose the information that hotele2is located inf2, although you just wanted to delete the contract.Even worse, when you translate the scheme into
then you actually omit FD
E->F, which would permit that the same hotele1gets two different locations, for examplef1andf2:Hence, split the table as recommended in the intro.