3NF normalized database
I am having trouble creating a 3NF normalized database. Can anyone help please? I can't see any dependencies. This is for a real estate site. The table fie开发者_Go百科lds are as follows:
ID - Type - Loc - Village - Purpose - Price Range - Picture 1 - Picture 2 - Picture 3 - Status - Properties - Description
Any help is appreciated.
If type is a reference to another table, it's ok, else you must put the types in another table. Also you can create a table for the pictures. Village can go in another table if you want more info about the villages after.
Typically you'd have tables like this:
PropertyType
Village
Purpose
Status
Property
and there could be many properties in a particular village. Purpose and PropertyType might be dependent -- you could not use a Cottage as a gathering place for a large audience, for example, though you could use a Cottage as a "Single Family Dwelling" or as "Bed and Breakfast". To represent this dependency you would need this intermediary table:
PropertyTypePurposes
propertytypeid
purposeid
where for each property type you would have one or more potential purposes. Then, in your Properties table, you would not reference Purposes directly but would reference PropertyTypePurposes:
alter table properties
add constraint FK_PROPERTIES_PROPERTYTYPEPURPOSES
foreign key (propertytypeid, purposeid) references PropertyTypePurposes(propertypeid, purposeid)
To be in 3NF, all you need to ensure is that you don't have any transitive functional depencencies (and that you don't have any non-full dependencies). If ID determines a tuple, and none of the other attributes can be used to say for certain what the value of some other attribute must be, you're not only in 3NF, but also in BCNF.
精彩评论