0% found this document useful (0 votes)
30 views19 pages

Unit 3

Uploaded by

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

Unit 3

Uploaded by

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

UNIT 3

Functional Dependencies and Normalization


Contents
• The importance of a good schema design, - Problems encountered
with bad schema designs, Motivation for normal forms,
• Functional Dependencies - Normal Forms Based on Primary Keys,
General Definitions of Second and Third Normal Forms, BCNF
The Importance of a Good
Schema Design
A good database design has many benefits and is a goal to achieve for every DBA −
Easy Retrieval of Information
• If the design is developed properly, then it would be easier to retrieve information. Correct design means the tables,
constraints, and relationships created are flawless.
Easier Modification
• Changes that you make to the value of a given field will not adversely affect the values of other fields within the table.
Easy to Maintain
• The database structure should be easy to maintain. The design is perfect if changes in one field is not affecting changes in
another field.
Information
• With a good design, you can enhance the quality and consistency of information.
Well-designed Database
• If the database is well defined, then the flaws and issues of a poorly designed database will not need to be addressed.
Problems of a Bad Schema
Design
Some of the problems are;
Referential Integrity:
• a poorly done database design leaves the application vulnerable to referential integrity issues.
Scalability:
• a poorly done design would struggle to scale when future application functionality is added.
Performance:
• over- or under-normalization can result in significant performance issues in the application that
attempts to work with the model.
Maintainability:
• a poor database design will make life miserable for developers attempting to code against the
model or to comprehend the model to diagnose issues.
Functional Dependencies
• The attributes of a table is said to be dependent on each other when an
attribute of a table uniquely identifies another attribute of the same table.
• For example: Suppose we have a student table with attributes: Stu_Id,
Stu_Name, Stu_Age. Here Stu_Id attribute uniquely identifies the
Stu_Name attribute of student table because if we know the student id
we can tell the student name associated with it. This is known as
functional dependency and can be written as Stu_Id->Stu_Name or in
words we can say Stu_Name is functionally dependent on Stu_Id.
• Formally: If column A of a table uniquely identifies the column B of same
table then it can represented as A->B (Attribute B is functionally
dependent on attribute A)
Functional Dependencies
Types of Functional Dependencies

• Trivial functional dependency


• Non-trivial functional dependency
• Multivalued dependency
• Transitive dependency
Functional Dependencies
Trivial functional dependency
• The Trivial dependency is a set of attributes which are called a trivial if
the set of attributes are included in that attribute.
• So, X -> Y is a trivial functional dependency if Y is a subset of X.

For example:
• Consider the table with two columns Emp_id and Emp_name.
• {Emp_id, Emp_name} -> Emp_id is a trivial functional dependency as
Emp_id is a subset of {Emp_id,Emp_name}.
Functional Dependencies
Non-trivial functional dependency
• This occurs when A->B holds true where B is not a subset of A. In a
relationship, if attribute B is not a subset of attribute A, then it is
considered as a non-trivial dependency.
For Example:
• (Company} -> {CEO} (if we know the Company, we knows the CEO
name). But CEO is not a subset of Company, and hence it's non-trivial
functional dependency.
Functional Dependencies
Multivalued dependency
• Multivalued dependency occurs in the situation where there are
multiple independent multivalued attributes in a single table. A
multivalued dependency is a complete constraint between two sets of
attributes in a relation. It requires that certain tuples be present in a
relation.
For Example
• In this example, maf_year and color are independent of each other
but dependent on car_model. In this example, these two columns are
said to be multivalue dependent on car_model.
Functional Dependencies
Multivalued dependency
This dependence can be represented like this:
car_model -> maf_year
car_model-> colour
Functional Dependencies
Transitive dependency
• A transitive is a type of functional dependency which happens when t
is indirectly formed by two functional dependencies.
For example:
• {Company} -> {CEO} (if we know the compay, we know its CEO's
name)
• {CEO } -> {Age} If we know the CEO, we know the Age
• Therefore according to the rule of rule of transitive dependency:
Functional Dependencies
Transitive dependency
• { Company} -> {Age} should hold, that makes sense because if we
know the company name, we can know his age.
• Note: You need to remember that transitive dependency can only
occur in a relation of three or more attributes.
Functional Dependencies
Advantages of dealing with Functional Dependencies
• Functional Dependency avoids data redundancy. Therefore same data
do not repeat at multiple locations in that database
• It helps you to maintain the quality of data in the database
• It helps you to defined meanings and constraints of databases
• It helps you to identify bad designs
• It helps you to find the facts regarding the database design
Normalization
Database Normalization is a technique of organizing the data in the database.
• Normalization is a systematic approach of decomposing tables to eliminate data redundancy and
undesirable characteristics like Insertion, Update and Deletion Anomalies.
• It is a multi-step process that puts data into tabular form by removing duplicated data from
the relation tables.
• Normalization is used for mainly two purposes,
1. Eliminating redundant (useless) data.
2. Ensuring data dependencies make sense i.e data is logically stored.
Problems Without Normalization
• Without Normalization, it becomes difficult to handle and update the database, without facing data
loss. Insertion, Updating and Deletion Anomalies are very frequent if Database is not Normalized
Normalization
1NF (First Normal Form) Rules
• Each cell has to be single valued.
• Entries in a column are same type.
• Rows uniquely identified (add unique ID, or add more columns to make unique).
• NB- the order of the rows and the order of the columns are irrelevant.
Normalization
2NF (Second Normal Form) Rules
• Check if your table is in the 1st normal form.
• Check if all attributes (non-key columns) are dependent on key.
• Those that don’t depend on the key need to be separated out into their own table.
• Create a junction table if there is need.

In general we are removing Partial dependencies on all data in our table.


Normalization
What are transitive functional dependencies?

• A transitive functional dependency is when changing a non-key column, might cause any of the other non-key columns to
change. Consider the table 1. Changing the non-key column Full Name may change Salutation.
Normalization
3NF (Third Normal Form) Rules
• Check that your tables are in the 2nd normal form.
• All fields (columns) can be determined only by the key in the table and no other column.
• In other words, remove all transitive functional dependencies.
• Introduce primary key and foreign key constraint.
Normalization
Fourth Normal Form
• No multi-valued dependencies

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