Logical Database Design and Relational Data Model Muhammad Nasir

21
Logical Database Design and Relational Data Model Muhammad Nasir [email protected]

description

Introduction To Normalization Normalization The process of decomposing relations with anomalies to produce smaller, well- structured relations

Transcript of Logical Database Design and Relational Data Model Muhammad Nasir

Page 1: Logical Database Design and Relational Data Model Muhammad Nasir

Logical Database Design and Relational Data Model

Muhammad [email protected]

Page 2: Logical Database Design and Relational Data Model Muhammad Nasir

Contents

Normalization Definitions Goals in Normalization 1NF 2NF 3NF

Page 3: Logical Database Design and Relational Data Model Muhammad Nasir

Introduction To Normalization

NormalizationThe process of decomposing relations with

anomalies to produce smaller, well-structured relations

Page 4: Logical Database Design and Relational Data Model Muhammad Nasir

Introduction To Normalization

Normal formA state of a relation that requires that certain

rules regarding relationships between attributes (or functional dependencies) are satisfied

Page 5: Logical Database Design and Relational Data Model Muhammad Nasir

Goals in Normalization

1. Minimize data redundancy, thereby avoiding anomalies and conserving storage space

2. Simplify the enforcement of referential integrity constraints

3. Make it easier to maintain data (insert, update, and delete)

4. Provide a better design that is an improved representation of the real world

Page 6: Logical Database Design and Relational Data Model Muhammad Nasir

Steps in Normalization

1. First normal form Any multi-valued attributes (also called repeating groups) have been removed, so there is a single value (possibly null) at the intersection of each row and column of the table

2. Second normal form Any partial functional dependencies have been removed (i.e., non-key attributes are identified by the whole primary key).

Page 7: Logical Database Design and Relational Data Model Muhammad Nasir

Steps in Normalization

3. Third normal form Any transitive dependencies have been removed (i.e., non-key attributes are identified by only the primary key).

4. Boyce-Codd normal form Any remaining anomalies that result from functional dependencies have been removed (because there was more than one possible primary key for the same non-keys).

5. Fourth normal form Any multi-valued dependencies have been removed.

6. Fifth normal form Any remaining anomalies have been removed.

Page 8: Logical Database Design and Relational Data Model Muhammad Nasir

Steps in Normalization

Page 9: Logical Database Design and Relational Data Model Muhammad Nasir

Normalization

Functional DependencyA constraint between two attributes in which

the value of one attribute is determined by the value of another attribute

Page 10: Logical Database Design and Relational Data Model Muhammad Nasir

Normalization 1. SSN →Name, Address, Birth-date A person’s name,

address, and birth date are functionally dependent on that person’s Social Security number (in other words, there can be only one Name, one Address, and one Birth-date for each SSN).

2. VIN → Make, Model, Color The make, model, and color of a vehicle are functionally dependent on the vehicle identification number (as above, there can be only one value of Make, Model, and Color associated with each VIN).

3. ISBN → Title, FirstAuthorName, Publisher The title of a book, the name of the first author, and the publisher are functionally dependent on the book’s international standard book number (ISBN).

Page 11: Logical Database Design and Relational Data Model Muhammad Nasir

Definitions

DeterminantThe attribute on the left side of the arrow in

a functional dependency Candidate key

An attribute, or combination of attributes, that uniquely identifies a row in a relation

Page 12: Logical Database Design and Relational Data Model Muhammad Nasir

Candidate key

A candidate key must satisfy the following 1. Unique identification For every row, the

value of the key must uniquely identify that row. This property implies that each non-key attribute is functionally dependent on that key.

2. Non-Redundancy No attribute in the key can be deleted without destroying the property of unique identification

Page 13: Logical Database Design and Relational Data Model Muhammad Nasir

Functional Dependency

Page 14: Logical Database Design and Relational Data Model Muhammad Nasir

Step 1: Convert to First Normal Form

1. There are no repeating groups in the relation (thus, there is a single fact at the intersection of each row and column of the table).

2. A primary key has been defined, which uniquely identifies each row in the relation.

Page 15: Logical Database Design and Relational Data Model Muhammad Nasir

Step 2: Convert to Second Normal Form

Second normal form (2NF)A relation in first normal form in which every

non-key attribute is fully functionally dependent on the primary key

Partial functional dependencyA functional dependency in which one or

more non-key attributes are functionally dependent on part (but not all) of the primary key

Page 16: Logical Database Design and Relational Data Model Muhammad Nasir

Invoice

Page 17: Logical Database Design and Relational Data Model Muhammad Nasir

Step 3: Convert to Third Normal Form

Third normal form (3NF)A relation that is in second normal form and

has no transitive dependencies Transitive dependency

A functional dependency between the primary key and one or more non-key attributes that are dependent on the primary key via another non-key attribute

Page 18: Logical Database Design and Relational Data Model Muhammad Nasir

REMOVING TRANSITIVE DEPENDENCIES

You can easily remove transitive dependencies from a relation by means of a three-step procedure:

1. For each non-key attribute (or set of attributes) that is a determinant in a relation, create a new relation. That attribute (or set of attributes) becomes the primary key of the new relation.

2. Move all of the attributes that are functionally dependent on the primary key of the new relation from the old to the new relation.

3. Leave the attribute that serves as a primary key in the new relation in the old relation to serve as a foreign key that allows you to associate the two relations.

Page 19: Logical Database Design and Relational Data Model Muhammad Nasir

Step 3: Convert to Third Normal Form

Page 20: Logical Database Design and Relational Data Model Muhammad Nasir

Step 3: Convert to Third Normal Form

Page 21: Logical Database Design and Relational Data Model Muhammad Nasir

The End

Thanks for listening Questions would be appreciated.