4. Order No Product ID Product Name Quantity
B005 JAP102459 Mouse 5
B005 DKT321573 USB 10
B005 OMG446789 LCD Monitor 20
B004 DKT321573 USB 15
B002 OMG446789 Laser Printer 3
Super Key
Super Key
A non-minimal Candidate
Key, that is to say one with
additional columns not
strictly required to ensure
uniqueness of the row.
Primary, Unique, Alternate
keys are subset of Super Key.
7. Person
id integer
licence_number integer
passport_number integer
name string
Candidate(Secondary) Key
Candidate Key
Is defined as the set of
fields from which primary
key can be selected. A
super key with no
repeated attribute.
8. Stud ID Roll No First Name Last Name Email
1 11 Tom Price abc@gmail.com
2 12 Nick Wright xyz@gmail.com
3 13 Dana Natan mno@gmail.com
Candidate Key
Alternate KeyPrimary Key
9. Student
id integer
name string
address string
department_id integer
Department
id integer
name string
Building_number integer
Foreign Key
Foreign Key
Is a column which is added
to create a relationship
with another table.
Primary Key
10. Order No Product ID Product Name Quantity
B005 JAP102459 Mouse 5
B005 DKT321573 USB 10
B005 OMG446789 LCD Monitor 20
B004 DKT321573 USB 15
B002 OMG446789 Laser Printer 3
Compound(Composite) Key
Compound Key
Has many fields which allow you
to uniquely recognize a specific
record. The difference between
compound and the compositekey
is that any part of the compound
key can be a foreign key, but the
composite key may or maybe not
a part of the foreign key.
11. Natural Key vs Surrogate Key
A natural key is made up of
naturally occurring fields in
the table. A surrogate key is a
meaningless value added to
uniquely identify a row.
Usually this is an identity or
‘autonumber’ column.
12. ID First Name Last Name
1 John Doe
2 Jane Austen
3 David Copperfield
Surrogate Key
Surrogate Key
An artificial key which
aims to uniquely
identify each record.
13. Normalization
•Normalization is a database design technique which
organizes tables in a manner that reduces
redundancy and dependency of data.
•It divides larger tables to smaller tables and links
them using relationships.
1st Normal
Form
2nd Normal
Form
3rd Normal
Form
Boyce-Codd
NF
4th Normal
Form
5th Normal
Form
6th Normal
Form
14. First Normal Form (1NF) Rules
•Each table cell should contain a single value.
•Each record needs to be unique.
15. First Normal Form (1NF)
Product ID Color Price
1 black, red 10
2 green 20
3 red 40
4 green, blue 30
5 white 50
This table is not in
first normal form
because the Color
column contains
multiple values.
18. Second Normal Form (2NF)
CustomerID Store ID Location
1 1 New York
1 3 London
2 1 New York
3 2 Washington
4 3 London
This table has a
composite primary
key(customerid, store
id). The non key
attribute(location)
depends on part of the
primary key(store id).
19. Store ID Location
1 New York
2 Washington
3 London
After decomposing
Customer ID Store ID
1 1
1 3
2 1
3 2
4 3
20. Third Normal Form (3NF) Rules
•Be in 2NF
•Has no transitive functional dependencies
21. Book ID Genre ID Genre Type Price
1 1 Fiction 100
2 2 Sports 110
3 1 Fiction 120
4 3 Travel 130
5 2 Sports 140
In the table Book ID
determines Genre ID, which
determines Genre Type.
Therefore Book ID
determines Genre Type via
Genre ID (transitive functional
dependency).
Third Normal Form (3NF)
22. After decomposing
Book ID Genre ID Price
1 1 100
2 2 110
3 1 120
4 3 130
5 2 140
Genre ID Genre Type
1 Fiction
2 Sports
3 Travel
23. Boyce-Codd Normal Form
(BCNF or 3.5 NF) Rules
•Be in 3NF
•For every functional dependency a->b a
should be super key(or candidate) of a table
24. Boyce-Codd Normal Form
(BCNF or 3.5 NF)
Student Course Teacher
Annie Laravel Greg
Antony Laravel John
David Yii Brian
James Yii Brian
Sara Laravel John
In the table Student
determines Course, which
determines Teacher. Course is
not a Super Key. So we need
to decompose the table to
have BCNF.
25. Course Teacher
Laravel Greg
Laravel John
Yii Brian
After decomposing
Student Course
Annie Laravel
Antony Laravel
David Yii
James Yii
Sara Laravel
26. Forth Normal Form (4NF) Rules
Eliminates independent many-to-one
relationships between columns.
•Be in BCNF
•A given relation may not contain more than
one multivalued attributes.
27. Student Subject Activity
100 Music Swimming
100 Accounting Swimming
100 Music Tennis
100 Accounting Tennis
150 Programming Yoga
In the table for Student are
multiple Subjects and
Activities. Therefore this is
not in 4NF.
Forth Normal Form (4NF)
29. Fifth and Sixth Normal Forms
(5NF, 6NF)
• A table is in 5th Normal Form only if it is in 4NF and it cannot be
decomposed into any number of smaller tables without loss of
data.
• 6th Normal Form is not standardized, yet however, it is being
discussed by database experts for some time. Hopefully, we
would have a clear & standardized definition for 6th Normal
Form in the near future...