0% found this document useful (0 votes)
22 views

Unit 4 - Lecture 17 - RDBMS

This document discusses normal forms in relational database design. It defines first normal form as requiring attributes to be single-valued and atomic. Second normal form requires relations to be in first normal form and have no partial dependencies. Third normal form eliminates transitive dependencies between non-prime attributes and keys. The document provides examples to illustrate how to decompose relations to satisfy each normal form.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Unit 4 - Lecture 17 - RDBMS

This document discusses normal forms in relational database design. It defines first normal form as requiring attributes to be single-valued and atomic. Second normal form requires relations to be in first normal form and have no partial dependencies. Third normal form eliminates transitive dependencies between non-prime attributes and keys. The document provides examples to illustrate how to decompose relations to satisfy each normal form.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 31

Unit -4

Relational Database Design – Atomic Domains


and First Normal Form

Lecture 17

21BCT3DA - Discipline Specific Core - RDBMS | ODD 2022-23


21BCT3DA - Discipline Specific Core - RDBMS | ODD 2022-23
Review of Previous Class Topic

• Extended ER Features
• Alternative Notations for Modelling data

21BCT3DA - Discipline Specific Core - RDBMS | ODD 2022-23


Topic Outcome

• Relational Database Design


• Atomic Domains and First Normal Form

21BCT3DA - Discipline Specific Core - RDBMS | ODD 2022-23


Relational Database Design

In general, the goal of relational database design is to


generate a set of relation schemas that allows us to store
information without unnecessary redundancy, yet also allows
us to retrieve information easily.
This is accomplished by designing schemas that are in an
appropriate normal form. To determine whether a relation
schema is in one of the desirable normal forms, we need
information about the real-world enterprise that we are
modeling with the database.

21BCT3DA - Discipline Specific Core - RDBMS | ODD 2022-23


Relational Database Design

Relational database design (RDD) models information and


data into a set of tables with rows and columns. Each row of a
relation/table represents a record, and each column
represents an attribute of data. The Structured Query
Language (SQL) is used to manipulate relational databases.

21BCT3DA - Discipline Specific Core - RDBMS | ODD 2022-23


Atomic Domains and First Normal Form

Normalization is the process of minimizing redundancy from a relation or set of


relations. Redundancy in relation may cause insertion, deletion, and update
anomalies. So, it helps to minimize the redundancy in relations. Normal forms are
used to eliminate or reduce redundancy in database tables.

21BCT3DA - Discipline Specific Core - RDBMS | ODD 2022-23


First Normal Form
If a relation contain composite or multi-valued attribute, it violates first normal
form or a relation is in first normal form if it does not contain any composite or
multi-valued attribute. A relation is in first normal form if every attribute in that
relation is singled valued attribute.
Example 1 – Relation STUDENT in table 1 is not in 1NF because of multi-valued
attribute STUD_PHONE. Its decomposition into 1NF has been shown in table 2.

21BCT3DA - Discipline Specific Core - RDBMS | ODD 2022-23


Second Normal Form
To be in second normal form, a relation must be in first normal form and relation
must not contain any partial dependency. A relation is in 2NF if it has No Partial
Dependency, i.e., no non-prime attribute (attributes which are not part of any
candidate key) is dependent on any proper subset of any candidate key of the
table.
Partial Dependency – If the proper subset of candidate key determines non-
prime attribute, it is called partial dependency.

21BCT3DA - Discipline Specific Core - RDBMS | ODD 2022-23


Second Normal Form

{Note that, there are many courses having the same course fee. }
Here,
COURSE_FEE cannot alone decide the value of COURSE_NO or STUD_NO;
COURSE_FEE together with STUD_NO cannot decide the value of COURSE_NO;
COURSE_FEE together with COURSE_NO cannot decide the value of STUD_NO;
Hence,
COURSE_FEE would be a non-prime attribute, as it does not belong to the one only candidate key {STUD_NO, COURSE_NO} ;
But, COURSE_NO -> COURSE_FEE, i.e., COURSE_FEE is dependent on COURSE_NO, which is a proper subset of the candidate key. N
prime attribute COURSE_FEE is dependent on a proper subset of the candidate key, which is a partial dependency and so this relation is not
2NF.
To convert the above relation to 2NF,
we need to split the table into two tables such as :
Table 1: STUD_NO, COURSE_NO
Table 2: COURSE_NO, COURSE_FEE

21BCT3DA - Discipline Specific Core - RDBMS | ODD 2022-23


Second Normal Form

21BCT3DA - Discipline Specific Core - RDBMS | ODD 2022-23


Second Normal Form

21BCT3DA - Discipline Specific Core - RDBMS | ODD 2022-23


Third Normal Form

21BCT3DA - Discipline Specific Core - RDBMS | ODD 2022-23


Another way of Explanation

21BCT3DA - Discipline Specific Core - RDBMS | ODD 2022-23


Normal Form
A large database defined as a single relation may result in data
duplication. This repetition of data may result in:
• Making relations very large.
• It isn't easy to maintain and update data as it would involve
searching many records in relation.
• Wastage and poor utilization of disk space and resources.
• The likelihood of errors and inconsistencies increases.

21BCT3DA - Discipline Specific Core - RDBMS | ODD 2022-23


What is Normalization?
• Normalization is the process of organizing the data in the database.
• Normalization is used to minimize the redundancy from a relation or set
of relations. It is also used to eliminate undesirable characteristics like
Insertion, Update, and Deletion Anomalies.
• Normalization divides the larger table into smaller and links them using
relationships.
• The normal form is used to reduce redundancy from the database table.

21BCT3DA - Discipline Specific Core - RDBMS | ODD 2022-23


Why do we need Normalization?

• The main reason for normalizing the relations is removing these


anomalies. Failure to eliminate anomalies leads to data redundancy and
can cause data integrity and other problems as the database grows.
Normalization consists of a series of guidelines that helps to guide you
in creating a good database structure.

21BCT3DA - Discipline Specific Core - RDBMS | ODD 2022-23


Types of Normal Forms:

21BCT3DA - Discipline Specific Core - RDBMS | ODD 2022-23


21BCT3DA - Discipline Specific Core - RDBMS | ODD 2022-23
Advantages of Normalization

• Normalization helps to minimize data redundancy.


• Greater overall database organization.
• Data consistency within the database.
• Much more flexible database design.
• Enforces the concept of relational integrity.

21BCT3DA - Discipline Specific Core - RDBMS | ODD 2022-23


First Normal Form (1NF)

• A relation will be 1NF if it contains an atomic value.


• It states that an attribute of a table cannot hold multiple values. It must
hold only single-valued attribute.
• First normal form disallows the multi-valued attribute, composite
attribute, and their combinations.

21BCT3DA - Discipline Specific Core - RDBMS | ODD 2022-23


First Normal Form (1NF)

• Example: Relation EMPLOYEE is not in 1NF because of multi-valued attribute


EMP_PHONE.

21BCT3DA - Discipline Specific Core - RDBMS | ODD 2022-23


First Normal Form (1NF)

• The decomposition of the EMPLOYEE table into 1NF has been shown below:

21BCT3DA - Discipline Specific Core - RDBMS | ODD 2022-23


Second Normal Form (2NF)
• In the 2NF, relational must be in 1NF.
• In the second normal form, all non-key attributes are fully functional dependent
on the primary key
Example: Let's assume, a school can store the data of teachers and the subjects they
teach. In a school, a teacher can teach more than one subject.

21BCT3DA - Discipline Specific Core - RDBMS | ODD 2022-23


Second Normal Form (2NF)
In the given table, non-prime attribute TEACHER_AGE is dependent on TEACHER_ID
which is a proper subset of a candidate key. That's why it violates the rule for 2NF.
To convert the given table into 2NF, we decompose it into two tables:

21BCT3DA - Discipline Specific Core - RDBMS | ODD 2022-23


Third Normal Form (3NF)
• A relation will be in 3NF if it is in 2NF and not contain any transitive partial
dependency.
• 3NF is used to reduce the data duplication. It is also used to achieve the data integrity.
• If there is no transitive dependency for non-prime attributes, then the relation must
be in third normal form.
I. A relation is in third normal form if it holds atleast one of the following conditions for
every non-trivial function dependency X → Y.
II. X is a super key.
III. Y is a prime attribute, i.e., each element of Y is part of some candidate key.

21BCT3DA - Discipline Specific Core - RDBMS | ODD 2022-23


Third Normal Form (3NF)

21BCT3DA - Discipline Specific Core - RDBMS | ODD 2022-23


Third Normal Form (3NF)
Candidate key: {EMP_ID}
Non-prime attributes: In the given table, all attributes except EMP_ID are
non-prime.
Here, EMP_STATE & EMP_CITY dependent on EMP_ZIP and EMP_ZIP
dependent on EMP_ID. The non-prime attributes (EMP_STATE, EMP_CITY)
transitively dependent on super key(EMP_ID). It violates the rule of third
normal form.
That's why we need to move the EMP_CITY and EMP_STATE to the new
<EMPLOYEE_ZIP> table, with EMP_ZIP as a Primary key.

21BCT3DA - Discipline Specific Core - RDBMS | ODD 2022-23


Third Normal Form (3NF)

21BCT3DA - Discipline Specific Core - RDBMS | ODD 2022-23


Third Normal Form (3NF)

21BCT3DA - Discipline Specific Core - RDBMS | ODD 2022-23


Next topic for Lect. 18

• Decomposition using Functional


Dependencies

21BCT3DA - Discipline Specific Core - RDBMS | ODD 2022-23

You might also like