Top Banner
13
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Normalisation - 2nd normal form
Page 2: Normalisation - 2nd normal form

NormalizationNormalization

What Normalization is forWhat Normalization is for

is to make sure that each database

table carries only the attributes

that actually actually describe describe

What is needed.What is needed.

Page 3: Normalisation - 2nd normal form

Normalisation is a technique used for designing relational database tables to minimise duplication of information. Data is normalised in order to redundancy and inconsistency, and to make it easier to maintain. Normalization generally involves splitting existing tables into multiple ones, which must be re-joined or linked each time a query is issued.

Normalisation provides rules that help:o Organise data efficientlyo Ensure that only related data are stored in the table.

Page 4: Normalisation - 2nd normal form

•Atomic data values, eliminates duplicate columns from the same table •Each row is uniquely identified; Needs a primary key, so each row can be unique

•Each field name is also unique

Page 5: Normalisation - 2nd normal form
Page 6: Normalisation - 2nd normal form

There are two goals of the normalization process:eliminate redundant dataeliminate redundant data (for example, storing the same data in more than one table) and ensure data dependenciesensure data dependencies make sense (only storing related data in a table). Both of these are worthy goals as they reduce the amount of space a database consumes and ensure that data is logically stored.

Page 7: Normalisation - 2nd normal form

First normal form (1NF)First normal form (1NF) sets the very basic rules for an organized database:

Eliminate duplicative columns from the same table. Create separate tables for each group of related data and identify each row with a unique column or set of columns (the primary key).

Second normal form (2NF)Second normal form (2NF) further addresses the concept of removing duplicative data:

Meet all the requirements of the first normal form. Remove subsets of data that apply to multiple rows of a table and place them in separate tables. Create relationships between these new tables and their predecessors through the use of foreign keys.

Third normal form (3NF)Third normal form (3NF) goes one large step further: Meet all the requirements of the second normal form. Remove columns that are not dependent upon the primary key.

Finally, fourth normal form (4NF)Finally, fourth normal form (4NF) has one additional requirement: Meet all the requirements of the third normal form. A relation is in 4NF if it has no multi-valued dependencies.

Page 8: Normalisation - 2nd normal form

Definition: In order to be in Second Normal Form, a relation must first fulfill the requirements to be in First Normal Form. Additionally, each nonkey attribute in the relation must be functionally dependent upon the primary key.

Page 9: Normalisation - 2nd normal form

Order # Customer Contact Person Total

1 Acme Widgets John Doe $134.23

2 ABC Corporation Fred Flintstone $521.24

3 Acme Widgets John Doe $1042.42

4 Acme Widgets John Doe $928.53

The relation is in First Normal Form, but not Second Normal Form:

Remove subsets of data that apply to multiple rows of a table and place them in Remove subsets of data that apply to multiple rows of a table and place them in separate tablesseparate tables

Page 10: Normalisation - 2nd normal form

Customer Contact Person

Acme Widgets John Doe

ABC Corporation Fred Flintstone

Order # Customer Total

1 Acme Widgets $134.23

2 ABC Corporation $521.24

3 Acme Widgets $1042.42

4 Acme Widgets $928.53

Page 11: Normalisation - 2nd normal form

The creation of two separate tables eliminates the dependency problem experienced in the previous case. In the first table, contact person is dependent upon the primary key -- customer name. The second table only includes the information unique to each order.Someone interested in the contact person for each order could obtain this information by performing a JOIN operation

Page 12: Normalisation - 2nd normal form

summary

the rules for second normal form are:• Non key attributes must depend on every part

of the primary key.• The table must already be in first normal form

Page 13: Normalisation - 2nd normal form

Advantages of normalization

• Normalization provides numerous benefits to a database. Some of the major benefits include the following :

• Greater overall database organization • Reduction of redundant data • Data consistency within the database • A much more flexible database design • A better handle on database security