23
DATA BASE NORMALIZATION By Prof. Manikandan Dept of Computer Application QMC College, Chennai [email protected]

DB Normalization by Prof.manikandan

Embed Size (px)

DESCRIPTION

DataBase Normalization Notes

Citation preview

Slide 1

Data Base NormalizationBy Prof. ManikandanDept of Computer ApplicationQMC College, [email protected]

NormalizationA logical design method which minimizes data redundancy and reduces design flaws.to improve storage efficiency, data integrity, and scalability. The normal forms break down large tables into smaller subsets.

Goal: - Eliminate redundant data in a DB. - Ensure data dependencies make sense.

Normalization BenefitsFacilitates data integration.Reduces data redundancy.Provides a robust architecture for retrievingand maintaining data.Compliments data modeling.Reduces the chances of data anomaliesoccurring.DBMS KeysPrimary Key: Uniquely identify records from the same table. Avoid duplicate values.

Foreign Keys: An attribute or a set of attributes of one table that is matched to candidate keys of another table (or even the same table). That is, a child table may reference the parent table for appropriate attribute values.

Candidate Keys: A minimal set of attributes in a table that uniquely identifies a record.When there is more than one attribute in the candidate key, it is called composite key.Normal FormsNormalization works through a series of stages called normal forms:First normal form (1NF)Second normal form (2NF)Third normal form (3NF)Boyce Codd normal form (BCNF)The highest level of normalization is not always desirable.First Normal Form (1NF)Each attribute must be atomicNo repeating columns within a row.No multi-valued columns.

1NF simplifies attributesQueries become easier.

First Normal Form (1NF)

Second Normal Form (2NF)Each attribute must be functionally dependent on the primary key. Functional dependencies are the relationships among the attributes within a relation.the property of one or more attributes that uniquely determines the value of other attributes.Any non-dependent attributes are moved into a smaller (subset) table.2NF improves data integrity. Prevents update, insert, and delete anomalies.

Functional Dependence

Name, dept_no, and dept_name are functionally dependent on emp_no. (emp_no -> name, dept_no, dept_name) Skills is not functionally dependent on emp_no since it is not unique to each emp_no.

Second Normal Form (2NF)

Third Normal Form (3NF)Transitive Dependencies:Is A Relationship Between Attributes Such That The Values Of One Attribute Is Dependent On, Or Determined By, The Values Of Another Attribute Which Is Not A Part Of The Key.Third Normal Form (3NF)Remove transitive dependencies.Transitive dependence - two separate entities exist within one table.Any transitive dependencies are moved into a smaller (subset) table.

3NF further improves data integrity.Prevents update, insert, and delete anomalies.

Transitive Dependence

Dept_no and dept_name are functionally dependent on emp_no however, department can be considered a separate entity.Third Normal Form (3NF)

Boyce-Codd Normal Form (BCNF)A relation is in BCNF if and only if every determinant is a candidate key. Notes: BCNF is a stronger form of 3NF BCNF => 3NF 3NF > BCNF

Violation of BCNF happen under specific conditions: A relation contains two (or more) composite candidate keys, which overlap and share at least one attribute in common.

SUMMARY

Normalization Process

Converting to a class diagram to normalized table

One to many relationship

Supplier(SID, Name, Address, City, State, Zip, Phone)Employee(EID, Name, Salary, Address, )

The many side becomes a key (underlined). Each PO has one supplier and employee.(Do not key SID or EID)Each supplier can receive many POs. (Key PO)Each employee can place many POs. (Key PO)One to many relationship sample data

Many to many relationship

Each POID can have many Items (key/underline ItemID).Each ItemID can be on many POIDs (key POID).N-Ary associations

Thank you..