0% found this document useful (0 votes)
29 views39 pages

Chapter 4

The document discusses database normalization. It defines normalization as a process of identifying logical associations between data items and designing a database without update anomalies. The document outlines the goals of normalization as reducing data redundancy and inconsistencies. It also defines several normalization forms including 1NF, 2NF, and 3NF. 1NF requires atomic values and removing repeating groups. Higher normal forms like 2NF and 3NF aim to remove partial and transitive dependencies. Functional dependencies are also discussed as the logical associations that determine the normalization process.

Uploaded by

Jonathan T
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views39 pages

Chapter 4

The document discusses database normalization. It defines normalization as a process of identifying logical associations between data items and designing a database without update anomalies. The document outlines the goals of normalization as reducing data redundancy and inconsistencies. It also defines several normalization forms including 1NF, 2NF, and 3NF. 1NF requires atomic values and removing repeating groups. Higher normal forms like 2NF and 3NF aim to remove partial and transitive dependencies. Functional dependencies are also discussed as the logical associations that determine the normalization process.

Uploaded by

Jonathan T
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 39

Database Design 7/21/2023

HiLCoE School of Computer Science & Technology


Chapter Four: Functional Dependency and Normalization

Course Title : Database Management Systems


Instructor name: Yitayew Solomon
E-mail address: yitayewsolomon3@gmail.com
Outlines of Discussion 2

• Normalization
• Functional Dependency (FD)
• Steps of Normalization
➢ First Normal Form (1NF)

➢ Second Normal Form (2NF)

➢ Third Normal Form (3NF)


Normalization
• A relational database is merely a collection of data, organized in a
particular manner.

• As the father of the relational database approach, Codd created a


series of rules (tests) called normal forms that help define that
organization One of the best ways to determine what information
should be stored in a database is to clarify what questions will be
asked of it and what data would be included in the answers.

7/21/2023 Fundamental Of Database System 3


Cont. …

• Database normalization is a series of steps followed to obtain a


database design that allows for consistent storage and efficient access
of data in a relational database.

• These steps reduce data redundancy and the risk of data becoming
inconsistent.

7/21/2023 Fundamental Of Database System 4


Cont. …
• NORMALIZATION is the process of identifying the logical
associations between data items and designing a database that will
represent such associations but without suffering the update anomalies
which are:

1. Insertion Anomalies

2. Deletion Anomalies

3. Modification Anomalies

7/21/2023 Fundamental Of Database System 5


Cont. …
• Normalization may reduce system performance since data will be cross
referenced from many tables.
• Thus de-normalization is sometimes used to improve performance, at the
cost of reduced consistency guarantees.
• Normalization normally is considered “good” if it is lossless decomposition.
• Normalization is the process of removing redundant(repetition) data from
your tables in order to, improve storage efficiency, data integrity and
Scalability.

7/21/2023 Fundamental Of Database System 6


Cont. …
• All the normalization rules will eventually remove the update anomalies that may
exist during data manipulation after the implementation.

• The update anomalies are; The type of problems that could occur in insufficiently
normalized table is called update anomalies which includes;

Insertion anomalies

• An "insertion anomaly" is a failure to place information about a new database


entry into all the places in the database where information about that new entry
needs to be stored. Additionally, we may have difficulty to insert some data.

7/21/2023 Fundamental Of Database System 7


Cont. …

• In a properly normalized database, information about a new entry


needs to be inserted into only one place in the database; in an
inadequately normalized database, information about a new entry may
need to be inserted into more than one.

• The purpose of normalization is to reduce the chances for anomalies to


occur in a database.

7/21/2023 Fundamental Of Database System 8


Cont. …
Deletion anomalies

• A "deletion anomaly" is a failure to remove information about an existing


database entry when it is time to remove that entry.

• Additionally, deletion of one data may result in lose of other information. In


a properly normalized database, information about an old, to-be-gotten-rid-
of entry needs to be deleted from only one place in the database; in an
inadequately normalized database, information about that old entry may
need to be deleted from more than one place.

7/21/2023 Fundamental Of Database System 9


Cont. …
Modification anomalies

• A modification of a database involves changing some value of the


attribute of a table. In a properly normalized database table, what ever
information is modified by the user, the change will be effected and
used accordingly.

• In order to avoid the update anomalies we in a given table, the solution


is to decompose it to smaller tables based on the rule of normalization.
7/21/2023 Fundamental Of Database System 10
Functional Dependency (FD)
• Before moving to the definition and application of normalization, it is
important to have an understanding of "functional dependency."

Data Dependency

• The logical associations between data items that point the database
designer in the direction of a good database design are referred to as
determinant or dependent relationships.

7/21/2023 Fundamental Of Database System 11


Cont. …

• Two data items A and B are said to be in a determinant or dependent


relationship if certain values of data item B always appears with
certain values of data item A.

• If the data item A is the determinant data item and B the dependent
data item then the direction of the association is from A to B and not
vice versa.

7/21/2023 Fundamental Of Database System 12


Cont. …

• The notation is: A→B which is read as; B is functionally dependent on A.

• In general, a functional dependency is a relationship among attributes.

• In relational databases, we can have a determinant that governs one or several other
attributes.
• Since the type of Wine served depends on the
type of Dinner, we say Wine is functionally
dependent on Dinner.
Dinner →Wine

7/21/2023 Fundamental Of Database System 13


Cont. …

• Since both Wine type and Fork type are determined by the Dinner type, we say Wine is
functionally dependent on Dinner and Fork is functionally dependent on Dinner.
✓ Dinner→Wine
✓ Dinner→Fork

7/21/2023 Fundamental Of Database System 14


Cont. …
Partial Dependency

• If an attribute which is not a member of the primary key is dependent on


some part of the primary key (if we have composite primary key) then that
attribute is partially functionally dependent on the primary key.

• Let {A,B} is the Primary Key and C is no key attribute.

Then if {A,B}→C and B→C

• Then C is partially functionally dependent on {A,B}

7/21/2023 Fundamental Of Database System 15


Cont. …
Full Functional Dependency

• If an attribute which is not a member of the primary key is not dependent on


some part of the primary key but the whole key (if we have composite
primary key) then that attribute is fully functionally dependent on the
primary key.

• Let {A,B} be the Primary Key and C is a non- key attribute Then if
{A,B}→C and B→C and A→C does not hold Then C Fully functionally
dependent on {A,B}
7/21/2023 Fundamental Of Database System 16
Cont. …
Transitive Dependency

• In mathematics and logic, a transitive relationship is a relationship of


the following form: "If A implies B, and if also B implies C, then A
implies C."

Example:

• If Mr X is a Human, and if every Human is an Animal, then Mr X


must be an Animal.
7/21/2023 Fundamental Of Database System 17
Cont. …

• Generalized way of describing transitive dependency is that:

✓If A functionally governs B, AND

✓If B functionally governs C

✓THEN A functionally governs C

• Provided that neither C nor B determines A i.e. (B / A and C / A)

7/21/2023 Fundamental Of Database System 18


Steps of Normalization
• We have various levels or steps in normalization called Normal Forms.

• The level of complexity, strength of the rule and decomposition increases as


we move from one lower level Normal Form to the higher.

• A table in a relational database is said to be in a certain normal form if it


satisfies certain constraints.

• A normal form below represents a stronger condition than the previous one
Normalization towards a logical design consists of the following steps:

7/21/2023 Fundamental Of Database System 19


Cont. …
✓Un-Normalized Form(UNF):
• Identify all data elements
✓First Normal Form(1NF):
• Find the key with which you can find all data i.e. remove any repeating
group
✓Second Normal Form(2NF):
• Remove part-key dependencies (partial dependency).
• Make all data dependent on the whole key.
7/21/2023 Fundamental Of Database System 20
Cont. …
✓Third Normal Form(3NF)

• Remove non-key dependencies (transitive dependencies). Make all


data dependent on nothing but the key.

• For most practical purposes, databases are considered normalized if


they adhere to the third normal form (there is no transitive
dependency).

7/21/2023 Fundamental Of Database System 21


First Normal Form (1NF)
• Requires that all column values in a table are atomic (e.g., a number is an
atomic value, while a list or a set is not).
• We have tow ways of achieving this:
1. Putting each repeating group into a separate table and connecting them
with a primary key-foreign key relationship
2. Moving these repeating groups to a new row by repeating the
nonrepeating attributes known as “flattening” the table. If so then Find
the key with which you can find all data

7/21/2023 Fundamental Of Database System 22


Cont. …
Definition: a table (relation) is in 1NF

If:

• There are no duplicated rows in the table. Unique identifier

• Each cell is single-valued (i.e., there are no repeating groups).

• Entries in a column (attribute, field) are of the same kind.

7/21/2023 Fundamental Of Database System 23


Cont. …

7/21/2023 Fundamental Of Database System 24


Cont. …

7/21/2023 Fundamental Of Database System 25


Cont. …
Second Normal form 2NF

• No partial dependency of a non key attribute on part of the primary key.

• This will result in a set of relations with a level of Second Normal Form.

• Any table that is in 1NF and has a single-attribute (i.e., a non-composite) key is
automatically also in 2NF.
• Definition: a table (relation) is in 2NF
If:
• It is in 1NF and
• If all non-key attributes are dependent on the entire primary key. i.e. no partial
dependency.

7/21/2023 Fundamental Of Database System 26


Cont. …

7/21/2023 Fundamental Of Database System 27


Cont. …
• Business rule: Whenever an employee participates in a project, he/she will
be entitled for an incentive.

• This schema is in its 1NF since we don’t have any repeating groups or
attributes with multi-valued property. To convert it to a 2NF we need to
remove all partial dependencies of non key attributes on part of the primary
key.

• {EmpID, ProjNo}→EmpName, ProjName, ProjLoc, ProjFund,


ProjMangID, Incentive

7/21/2023 Fundamental Of Database System 28


Cont. …

But in addition to this we have the following dependencies

• FD1: {EmpID}→EmpName

• FD2: {ProjNo}→ProjName, ProjLoc, ProjFund, ProjMangID

• FD3: {EmpID, ProjNo}→ Incentive

7/21/2023 Fundamental Of Database System 29


Cont. …

• As we can see, some non key attributes are partially dependent on


some part of the primary key. This can be witnessed by analyzing the
first two functional dependencies (FD1 and FD2).

• Thus, each Functional Dependencies, with their dependent attributes


should be moved to a new relation where the Determinant will be the
Primary Key for each.

7/21/2023 Fundamental Of Database System 30


Cont. …

7/21/2023 Fundamental Of Database System 31


Cont. …
Third Normal Form (3NF)

• Eliminate Columns dependent on another non-Primary Key - If attributes do not


contribute to a description of the key; remove them to a separate table.

• This level avoids update and deletes anomalies.

• Definition: a Table (Relation) is in 3NF

If:

• It is in 2NF and

• There are no transitive dependencies between a primary key and Non-primary key
attributes.

7/21/2023 Fundamental Of Database System 32


Cont. …

7/21/2023 Fundamental Of Database System 33


Cont. …

• This schema is in its 2NF since the primary key is a single attribute
and there are no repeating groups (multi valued attributes).

• Let’s take StudID, Year and Dormitary and see the dependencies.

• StudID→Year AND Year→Dormitary And Year can not determine


StudID and Dormitary can not determine StudID Then transitively
StudID→Dormitary

7/21/2023 Fundamental Of Database System 34


Cont. …

• To convert it to a 3NF we need to remove all transitive dependencies


of non key attributes on another non-key attribute.

• The non-primary key attributes, dependent on each other will be


moved to another table and linked with the main table using Candidate
Key- Foreign Key relationship.

7/21/2023 Fundamental Of Database System 35


Cont. …

7/21/2023 Fundamental Of Database System 36


Cont. …

• Generally, even though there are other four additional levels of


Normalization, a table is said to be normalized if it reaches 3NF.

• A database with all tables in the 3NF is said to be Normalized


Database.

• Mnemonic for remembering the rationale for normalization up to 3NF


could be the following:

7/21/2023 Fundamental Of Database System 37


Cont. …
1. No Repeating or Redundancy: no repeating fields in the table.

2. The Fields Depend Upon the Key: the table should solely depend on
the key.

3. The Whole Key: no partial key based dependency.

4. And Nothing But the Key: no inter data dependency.

5. So Help Me Codd: since Codd came up with these rules.

7/21/2023 Fundamental Of Database System 38


7/21/2023 Fundamental Of Database System 39

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy