Chapter 5-T323 Introduction to the Relational Database
Chapter 5-T323 Introduction to the Relational Database
Databases
Chapter 5- Normalisation
• Functional Dependency
2
Entity Integrity: Selecting Primary Keys
3
Natural Keys and Primary Keys
• Natural key or natural identifier: real-world identifier used to uniquely identify real-world
objects
• Familiar to end users and forms part of their day-to-day business vocabulary
4
Primary Key Guidelines
• Non intelligent
• Preferably single-attribute
• Preferably numeric
• Security-compliant
5
When to Use Composite Primary Keys
• Represented in the data model as two separate entities in a strong identifying relationship
6
The M:N Relationship Between Student and Class
• Determination
• State in which knowing the value of one attribute makes it possible to determine the
value of another
• Establishes the role of a key
• Based on the relationships among the attributes
• Functional dependence: value of one or more attributes determines the value of one or
more other attributes
• Determinant: attribute whose value determines another
• Dependent: attribute whose value is determined by the other attribute
• Full functional dependence: entire collection of attributes in the determinant is necessary
for the relationship
8
Types of Keys
9
Types of Keys Continued …
• Unknown attribute value, known but missing attribute value, or inapplicable condition
• Referential integrity: every reference to an entity instance by another entity instance is valid
• Foreign key: primary key of one table that has been placed into another table to create a
common attribute
10
Database Tables and Normalization
• Normal forms
11
Database Tables and Normalization Continued
• Properly designed 3NF structures meet the requirement of fourth normal form (4NF)
12
The Need for Normalization
• Improves the existing data structure and creates an appropriate database design
13
The Normalization Process
• Objective is to ensure that each table conforms to the concept of well-formed relations
• Each row/column intersection contains only one value and not a group of values
14
The Normalization Process
15
The Normalization Process
16
Functional Dependency
• A functional dependency occurs when the value of one (set of) attribute(s) determines the
value of a
second (set of) attribute(s):
StudentID → StudentName
StudentID → (DormName, DormRoom, Fee)
• The attribute on the left side of the functional dependency is called the determinant.
17
Composite Determinants
18
The Normalization Process
• Partial dependency: functional dependence in which the determinant is only part of the primary key
• Assumption: one candidate key
• Straight forward
• Easy to identify
• Transitive dependency: attribute is dependent on another attribute that is not part of the primary
key
• More difficult to identify among a set of data
• Occur only when a functional dependence exists among nonprime attributes
19
Conversion to First Normal Form (1NF)
• Repeating group: group of multiple entries of same type can exist for any single key
attribute occurrence
• Reduces data redundancies
• Three step procedure
• Eliminate the repeating groups
• Identify the primary key
• Identify all dependencies
• Dependency diagram: depicts all dependencies found within given table structure
• Overview of all relationships among table’s attributes
• Less likely that an important dependency will be overlooked
20
Conversion to First Normal Form (1NF)
Conversion to Emp_Id
123456
Name
Smith John
Pnumber
1
Hours
32.5
2
7.5
10
10
10
10
20 10
1 8
22
Conversion to First Normal Form- Result
Emp_Id Name
123456 1 32.5
123456 2 7.5
333444 1 8
333444 2 10
333444 3 10
23
Conversion to Second Normal Form (2NF)
• Conversion to 2NF occurs only when the 1NF has a composite primary key
• If the 1NF has a single-attribute primary key, then the table is automatically in 2NF
24
Dependency Diagram
26
Conversion to Third Normal Form (3NF)
27
Third Normal
Form (3NF)
Conversion
Results
28
The Boyce-Codd Normal Form
• Equivalent to 3NF when the table contains only one candidate key
• Violated only when the table contains more than one candidate key
29
A Table That is in 3NF but Not
In BCNF
• All attributes must be dependent on the primary key, but they must be independent of
each other
• Is in 3NF
32
Tables With
Multivalued
Dependencies
• Proposed entities must meet required the normal form before table structures are created
34
Denormalization
• Design goals
35
Denormalization Continued …
• Joining a larger number of tables
36
Any Questions
37