5 normal forms in relational database theory

Post on 15-Apr-2017

293 Views

Category:

Software

7 Downloads

Preview:

Click to see full reader

TRANSCRIPT

FIVE NORMAL FORMS IN RELATIONAL DATABASE THEORY- AIME

TODAY’s CONTENT

Why we have to learn database normalization Bad Relational Database Design – unnormalized 5 Normalization Forms Better Relational Database Design - normailized Conclusion

Why normalization?

Database Design Minimize Data Redundancy from UPDATE ANOMALIES

UPDATE ANOMALIES Insertion anomalies Deletion anomalies Modification anomalies

Update Anomalies

Insert?

Insert? DATA REDUNDANCY!

Delete?

Delete? OTHER IMPORTANT INFORMATIONS MIGHT BE DELETED

Modify?

Modify? MIGHT CAUSE INCONSISTENCY PROBLEM

BAD DATABASE DESIGN

Normalization

Unnormalization form

1st normalization form

2nd normalization

form

3rd normalization form

4th normalization form

5th normalization form

Remove repeating

group

Remove partial

dependencies

Remove transitive

dependencies

Remove remaining

anomalies from functional

dependencies

Remove multi-value

dependencies

join dependencies

Unnormalized Form

Unnormalized Form to 1st Normalized Form

1st Normalized Form problem

Data Redundancy Might cause inconsistency problem

Move to 2nd Normalized Form

Conditions It’s already in 1st normalized form All attributes have fully functional dependency with primary key, NOT partial dependency Get rid of Partial dependencies

Move to 2nd Normalized Form

Partial Dependency Non-prime field(s) depends on one primary key Student_ID + Course_ID Firstname, Surname, Cum.GPA, Position_ID, Position, Scholarship, Course_ID, Course, Credit, Grade, Lecturer_ID,

Lecturer Student_ID Firstname, Surname, Cum.GPA, Position_ID, Position, Scholarship Course_ID Course, Credit, Grade, Lecturer_ID, Lecturer Student_ID + Course_ID Grade

PK PK

PK: Primary KeyFK: Foreign Key

FK FK

2nd Normalized Form

Separate into relation tables...

PK

PK

Student Relation

Course Relation

FK FK

Student-Course Relation Table

Move to 3rd Normalized Form

Conditions It’s already in 2nd normalized form Get rid of Transitive Dependency

PK

PK

Student Relation

Course Relation

FK FK

Student-Course Relation Table

Move to 3rd Normalized Form

Transitive Dependency Other attributes, those are not a primary key, cannot define the value of

other attributes

PK

Student Relation

Non-PK

3rd Normalized Form

Separate into relation tables...

PK

PK

Student Relation

Course Relation

FK FK

Student-Course Relation

FKPK Position Relation

3rd Normalized Form

Separate into relation tables...

PKStudent Relation

FK FK

Student-Course Relation

FKPK Position Relation

PK Course Relation FK PK Lecturer Relation

Move to 4th Normalized Form

Conditions It’s in 3rd normalized form Get rid of multi-valued dependencies

PK

PK

Student Relation

Course Relation

FK FK

Student-Course Relation

FKPK Position Relation

FK PK Lecturer Relation

Move to 4th Normalized Form

Conditions It’s in 3rd normalized form Get rid of multi-valued dependencies

PK

PK

Student Relation

Course Relation

FK FK

Student-Course Relation

FKPK Position Relation

FK PK Lecturer Relation

Add Research for each lecturer

Move to 4th Normalized Form

Multi-valued Dependencies AB; Lecturer_IDLecturer AC; Lecturer_IDResearch But B and C is independent

A B C

PK

PK

Lecturer Relation

Lecturer-Research Relation

Final Form – 4th Normalized FormPK

PK

Student Relation

Course Relation

FK FK

Student-Course Relation

FKPK Position Relation

FK PK Lecturer Relation PK Lecturer-Research Relation

5th Normalized Form

Separate more relation and it’s able to join back without spurious tuple occurance

No spurious tuple

PK Position RelationPK Position Relation

Supurios Tuple Example

????

Spurious tuple exist!!

PK

PK

Student Relation

Course Relation

FK FK

Student-Course Relation

FKPK Position Relation

FK PK Lecturer Relation PK Lecturer-Research Relation

OLD version

NEW version

Conclusion

The purpose of normalization is to Reduce data redundacy Prevent data inconsistency

Trade-off Performance

The factors to be considered while normalization Single-valued vs Multivalued Dependencies

Partial dependency Transitive dependency Functional dependency Multivalued dependency

Key and non-Key field relationship

top related