Presentation is loading. Please wait.

Presentation is loading. Please wait.

Normalization. Database Normalization Database normalization is the process of removing redundant data from your tables in to improve storage efficiency,

Similar presentations


Presentation on theme: "Normalization. Database Normalization Database normalization is the process of removing redundant data from your tables in to improve storage efficiency,"— Presentation transcript:

1 Normalization

2 Database Normalization Database normalization is the process of removing redundant data from your tables in to improve storage efficiency, data integrity, and scalability. Database normalization is the process of removing redundant data from your tables in to improve storage efficiency, data integrity, and scalability. In the relational model, methods exist for quantifying how efficient a database is. These classifications are called normal forms (or NF), and there are algorithms for converting a given database between them. In the relational model, methods exist for quantifying how efficient a database is. These classifications are called normal forms (or NF), and there are algorithms for converting a given database between them. Normalization generally involves splitting existing tables into multiple ones, which must be re-joined or linked each time a query is issued. Normalization generally involves splitting existing tables into multiple ones, which must be re-joined or linked each time a query is issued.

3 History Edgar F. Codd first proposed the process of normalization and what came to be known as the 1st normal form in his paper A Relational Model of Data for Large Shared Data Banks Codd stated: Edgar F. Codd first proposed the process of normalization and what came to be known as the 1st normal form in his paper A Relational Model of Data for Large Shared Data Banks Codd stated: “There is, in fact, a very simple elimination procedure which we shall call normalization. Through decomposition nonsimple domains are replaced by ‘domains whose elements are atomic (nondecomposable) values.’”

4 Normal Form Edgar F. Codd originally established three normal forms: 1NF, 2NF and 3NF. There are now others that are generally accepted, but 3NF is widely considered to be sufficient for most applications. Edgar F. Codd originally established three normal forms: 1NF, 2NF and 3NF. There are now others that are generally accepted, but 3NF is widely considered to be sufficient for most applications.

5 Table 1 TitleAuthor1 Author 2 ISBNSubjectPagesPublisher Database System Concepts Abraham Silberschatz Henry F. Korth 0072958863 MySQL, Computers 1168McGraw-Hill Operating System Concepts Abraham Silberschatz Henry F. Korth 0471694665Computers944McGraw-Hill

6 Table 1 problems This table is not very efficient with storage. This table is not very efficient with storage. This design does not protect data integrity. This design does not protect data integrity. Third, this table does not scale well. Third, this table does not scale well.

7 First Normal Form 1NF requires NO Repeating Groups 1NF requires NO Repeating Groups This greatly simplifies searching and management This greatly simplifies searching and management In Table 1 we have more than one author field, In Table 1 we have more than one author field, Also, our subject field contains more than one piece of information. Also, our subject field contains more than one piece of information.

8 First Normal Table Table 2 Table 2 TitleAuthorISBNSubjectPagesPublisher Database System Concepts Abraham Silberschatz 0072958863MySQL1168McGraw-Hill Database System Concepts Henry F. Korth 0072958863Computers1168McGraw-Hill Operating System Concepts Henry F. Korth 0471694665Computers944McGraw-Hill Operating System Concepts Abraham Silberschatz 0471694665Computers944McGraw-Hill

9 We now have two rows for a single book but.. We now have two rows for a single book but.. 2NF requires Eliminating Redundant Data 2NF requires Eliminating Redundant Data A better solution would be to separate the data into separate tables- an Author table and a Subject table to store our information, removing that information from the Book table: A better solution would be to separate the data into separate tables- an Author table and a Subject table to store our information, removing that information from the Book table:

10 Subject_IDSubject 1MySQL 2Computers Author_ID Last Name First Name 1SilberschatzAbraham 2KorthHenry ISBNTitlePagesPublisher0072958863 Database System Concepts 1168McGraw-Hill 0471694665 Operating System Concepts 944McGraw-Hill Subject Table Author Table Book Table

11 Each table has a primary key, A primary key value must be non-null and unique within the table. Each table has a primary key, A primary key value must be non-null and unique within the table. We implement the book – author and book – subject many to many relationships using intersection tables. We implement the book – author and book – subject many to many relationships using intersection tables.

12 Relationships ISBNAuthor_ID 00729588631 00729588632 04716946651 04716946652 ISBNSubject_ID00729588631 00729588632 04716946652 Book_Author Table Book_Subject Table

13 Second Normal Form 2NF also says Eliminate Redundancy of data in vertical columns. 2NF also says Eliminate Redundancy of data in vertical columns. We implement the book – publisher one to many relationship as parent and child tables. We implement the book – publisher one to many relationship as parent and child tables.

14 2NF Table Publisher_ID Publisher Name 1McGraw-Hill ISBNTitlePagesPublisher_ID0072958863 Database System Concepts 11681 0471694665 Operating System Concepts 9441 Publisher Table Book Table

15 2NF The other requirement for Second Normal Form is that all non-key attributes must depend on the key. The other requirement for Second Normal Form is that all non-key attributes must depend on the key. If we have a composite (multi-attribute) key then All non-key attributes must depend on the entire key. If we have a composite (multi-attribute) key then All non-key attributes must depend on the entire key.

16 Third Normal Form Third normal form (3NF) requires that there are no functional dependencies of non-key attributes on something other than a candidate key. Third normal form (3NF) requires that there are no functional dependencies of non-key attributes on something other than a candidate key. A table is in 3NF if all of the non-primary key attributes are mutually independent A table is in 3NF if all of the non-primary key attributes are mutually independent That is, there are NO transitive dependencies That is, there are NO transitive dependencies


Download ppt "Normalization. Database Normalization Database normalization is the process of removing redundant data from your tables in to improve storage efficiency,"

Similar presentations


Ads by Google