Professional Documents
Culture Documents
First Normal Form: Functional Dependency
First Normal Form: Functional Dependency
First Normal Form: Functional Dependency
FUNCTIONAL DEPENDENCY
Recap.
Third normal form. For attributes X and Y in a table, if it is invalid to have two identical values of
Normalising X with different values of Y
then Y is functionally dependent on X.
Reference:
X (The Determinant) - Key Field(s)
Connolly & Begg, Database Systems,
Y ...... - Non-Key Field(s)
Fifth Edition pp 365-387.
Eg
Fourth Edition pp 388-411.
Student number Student name
Definition Definition
A table is in first normal form (1NF) if the intersection of each A table is in 2NF if it is in 1NF and every non-key attribute is
row with each column contains exactly one value. fully functionally dependant on any candidate key.
THIRD NORMAL FORM
Definition
A table is in 3NF if it is in 2NF and there are no transitive
dependencies of any non-key attributes on the key.
Transitive dependency:
attribute C depends transitively on attribute A if there is an
attribute B such that A → B, B → C
Functional Dependencies
Order
Ordnum Date Custnum Cname Caddress Prodnum Description Price Quant
The process of normalization:
1001 1/10/16 1122 Brown Stirling X2323 Taillight 166 1
S4545 Bulb 23 2
1. Write down the functional dependencies in each relation.
S2020 Connector 62 2
2. Separate out repeating fields. Make sure that each relation contains the key of 1002 1/10/16 1122 Brown Stirling S4545 Bulb 23 2
the original relation and sufficient other attributes to uniquely identify each F4545 Connector 62 1
tuple.
1003 1/11/16 3232 Brown Stirling F4545 Connector 62 2
3. Check that the functional dependencies do not violate 2nd Normal form D1212 Clip 62 1
4. Check that the functional dependencies do not violate 3rd Normal form
If it is invalid to have two identical values of X with different values of
Y then Y is functionally dependent on X. ie X Y
What functional dependencies can you deduce from the data in Order?
Anomalies First Normal Form
Order Order
Ordnum Date Custnum Cname Caddress Prodnum Description Price Quant Ordnum Date Custnum Cname Caddress Prodnum Description Price Quant
1001 1/10/16 1122 Brown Stirling X2323 Taillight 166 1 1001 1/10/16 1122 Brown Stirling X2323 Taillight 166 1
S4545 Bulb 23 2 S4545 Bulb 23 2
S2020 Connector 62 2 S2020 Connector 62 2
1002 1/10/16 1122 Brown Stirling S4545 Bulb 23 2 1002 1/10/16 1122 Brown Stirling S4545 Bulb 23 2
F4545 Connector 62 1 F4545 Connector 62 1
1003 1/11/16 3232 Brown Stirling F4545 Connector 62 2 1003 1/11/16 3232 Brown Stirling F4545 Connector 62 2
D1212 Clip 62 1 D1212 Clip 62 1
T1
Functional Dependencies:
Ordnum -> Date, Custnum
T2 Custnum -> Cname, Caddress
Prodnum -> Description, Price
Ordnum, Prodnum -> Quant
Second normal form Second normal form
A table is in 2NF if it is in 1NF and every non-key attribute is fully functionally A table is in 2NF if it is in 1NF and every non-key attribute is fully functionally
dependant on any candidate key. dependant on any candidate key.
Which table has a compound key? Are there attributes that are dependent on one Which table has a compound key? Are there attributes that are dependent on one
or other of the attributes in the compound key? or other of the attributes in the compound key?
How can the attributes be split so that they are in second normal form? How can the attributes be split so that they are in second normal form?
In 1NF: In 1NF: In 2NF: T2.1
T2 T2
T2.2
A table is in 3NF if it is in 2NF and there are no transitive dependencies of any A table is in 3NF if it is in 2NF and there are no transitive dependencies of any
non-key attributes on the key. non-key attributes on the key.
Are there attributes that are dependent on one or other of the attributes that are Are there attributes that are dependent on one or other of the attributes that are
not the key? not the key?
How can the attributes be split so that they are in third normal form? How can the attributes be split so that they are in third normal form?
T1 T1 T1.1
Functional Dependencies:
T2.1 Ordnum -> Date, Custnum T2.1
Custnum -> Cname, Caddress T1.2
T2.2 Prodnum -> Description, Price T2.2
Ordnum, Prodnum -> Quant
Third normal form Third normal form
In 3NF: In 3NF:
T1.2 Customer
Normalisation produces a set of table structures equivalent to those produced by Normalisation produces a set of table structures equivalent to those produced by
logical design. logical design.
By looking at the primary key/foreign key connections, it is possible to deduce By looking at the primary key/foreign key connections, it is possible to deduce
the structure to the ER model that would generate the logical design. Some the structure to the ER model that would generate the logical design. Some
assumptions are necessary. assumptions are necessary.
Customer
Order line
Normalisation and the ER model Normalisation and the ER model
Normalisation produces a set of table structures equivalent to those produced by Normalisation produces a set of table structures equivalent to those produced by
logical design. logical design.
By looking at the primary key/foreign key connections, it is possible to deduce By looking at the primary key/foreign key connections, it is possible to deduce
the structure to the ER model that would generate the logical design. Some the structure to the ER model that would generate the logical design. Some
assumptions are necessary. assumptions are necessary.
Ordered_on Ordered_on
Order line Order line
Customer Customer
Product Product
Ordered_on Ordered_on
Order line Order line Order Customer
Has_item Placed
CS990 Database Fundamentals
CS952 Database & Web Systems Development
Databases content: