Unit 3
Unit 3
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.
• 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