normalization - mr. ahmad al-ghoul data design. 2 learning objectives explain the concept of table...

15
normalization normalization - Mr. Ahmad Al-Ghoul - Mr. Ahmad Al-Ghoul Data Design Data Design

Upload: andrew-phelps

Post on 31-Dec-2015

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Normalization - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Explain the concept of table design  Explain unnormalized design and the first

normalizationnormalization

- Mr. Ahmad Al-Ghoul- Mr. Ahmad Al-Ghoul

Data DesignData Design

Page 2: Normalization - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Explain the concept of table design  Explain unnormalized design and the first

22

learning Objectiveslearning Objectives

Explain the concept of Explain the concept of table designtable design

Explain unnormalized Explain unnormalized design and the first design and the first normal form (1NF)normal form (1NF)

Page 3: Normalization - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Explain the concept of table design  Explain unnormalized design and the first

33

NormalizationNormalization NormalizationNormalization

Normalization is a process by which analysts identify and Normalization is a process by which analysts identify and correct inherent problems and complexities in their table correct inherent problems and complexities in their table designs. designs.

Table designTable design A table design specifies the fields and identifies the A table design specifies the fields and identifies the

primary key in a particular table or file. primary key in a particular table or file. You will use normalization to develop an overall database You will use normalization to develop an overall database

design that is simple, flexible, and free of data redundancydesign that is simple, flexible, and free of data redundancy In addition to being simpler and more stable, normalized In addition to being simpler and more stable, normalized

data structure are more easily maintained than other data data structure are more easily maintained than other data structurestructure

Involves four stages: unnormalized design, first normal Involves four stages: unnormalized design, first normal form, second normal form, and third normal formform, second normal form, and third normal form

Most business-related databases must be designed in third Most business-related databases must be designed in third normal formnormal form

Page 4: Normalization - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Explain the concept of table design  Explain unnormalized design and the first

44

NormalizationNormalization

Standard Notation FormatStandard Notation Format Designing tables is easier if you use a standard Designing tables is easier if you use a standard

notation formatnotation format to show a table’s structure, to show a table’s structure, fields, and primary keyfields, and primary key

Standard notation format starts with the name Standard notation format starts with the name of the table, followed by a parenthetical of the table, followed by a parenthetical expression that contains the fieldnames expression that contains the fieldnames separated by commas, the primary key field is separated by commas, the primary key field is underlinedunderlined

Example: NAME (Example: NAME (FIELD 1FIELD 1, FIELD 2, FIELD 3), FIELD 2, FIELD 3)

Page 5: Normalization - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Explain the concept of table design  Explain unnormalized design and the first

55

NormalizationNormalization

Repeating Groups and Unnormalized DesignRepeating Groups and Unnormalized Design Repeating group: is a set of one or more fields Repeating group: is a set of one or more fields

that can occur any number of times in a single that can occur any number of times in a single record, with each occurrence having different record, with each occurrence having different values.values.

Often occur in manual documents prepared by usersOften occur in manual documents prepared by users Unnormalized designUnnormalized design

An unnormalized record is one that contains a An unnormalized record is one that contains a repeating group, which means that a single record has repeating group, which means that a single record has multiple occurrences of a particular field, with each multiple occurrences of a particular field, with each occurrence having different values. occurrence having different values.

Page 6: Normalization - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Explain the concept of table design  Explain unnormalized design and the first

66

NormalizationNormalization

In the ORDER table design, records 1 and 2 have repeating groups because they contain several products. ORDER-NUM is the primary key for the ORDER table, and PRODUCT-NUM serves as a primary key for the repeating group. Because it contains a repeating group, the ORDER table design is unnormalized.

Repeating groups

[1]

Page 7: Normalization - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Explain the concept of table design  Explain unnormalized design and the first

77

NormalizationNormalization

Now let’s review the unnormalized Now let’s review the unnormalized ORDER table design. Following the ORDER table design. Following the notation guidelines, you can describe it notation guidelines, you can describe it as follows:as follows: ORDER (ORDER (ORDER-NUMORDER-NUM, ORDER-DATE, , ORDER-DATE,

((PRODUCT-NUMPRODUCT-NUM, PRODUCT-DESC, NUM-, PRODUCT-DESC, NUM-ORDERED))ORDERED))

The ORDER-NUM field is underlined to show that The ORDER-NUM field is underlined to show that it is the primary keyit is the primary key

The PRODUCT-NUM is also underlined because it The PRODUCT-NUM is also underlined because it acts as the primary key of the repeating groupacts as the primary key of the repeating group

Page 8: Normalization - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Explain the concept of table design  Explain unnormalized design and the first

88

NormalizationNormalization

First Normal FormFirst Normal Form A table is in first normal form (1NF) if it does not A table is in first normal form (1NF) if it does not

contain a repeating groupcontain a repeating group To convert, you must expand the table’s primary To convert, you must expand the table’s primary

key to include the primary key of the repeating key to include the primary key of the repeating groupgroup

Let us look to previous example againLet us look to previous example again When you expand the primary key of ORDER When you expand the primary key of ORDER

table to include PRODUCT-NUM, you eliminate table to include PRODUCT-NUM, you eliminate the repeating group and the ORDER table is now the repeating group and the ORDER table is now in 1NFin 1NF

ORDER (ORDER (ORDER-NUMORDER-NUM, ORDER-DATE, , ORDER-DATE, PRODUCT-PRODUCT-NUMNUM, PRODUCT-DESC, NUM-ORDERED), PRODUCT-DESC, NUM-ORDERED)

Page 9: Normalization - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Explain the concept of table design  Explain unnormalized design and the first

99

NormalizationNormalization

The ORDER table as it appears in 1NF. The repeating groups have been eliminated. Notice that the repeating group for order 40311 has become three separate records, and the repeating group for order 40312 has become two separate records. The 1NF primary key is a combination of ORDER-NUM and PRODUCT-NUM, which uniquely identifies each record.

[1]

Page 10: Normalization - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Explain the concept of table design  Explain unnormalized design and the first

1010

NormalizationNormalization

Note that neither ORDER-NUM nor Note that neither ORDER-NUM nor PRODUCT-NUM does not uniquely identify PRODUCT-NUM does not uniquely identify each product in a multiple item producteach product in a multiple item product

Each record must reflect a specific product Each record must reflect a specific product in a specific order, you need both fields, in a specific order, you need both fields, ORDER-NUM and PRODUCT-NUM, to ORDER-NUM and PRODUCT-NUM, to identify a single record uniquely.identify a single record uniquely.

The primary key in this example is the The primary key in this example is the combination of two fields: ORDER-NUM combination of two fields: ORDER-NUM and PRODUCT-NUMand PRODUCT-NUM

Page 11: Normalization - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Explain the concept of table design  Explain unnormalized design and the first

1111

NormalizationNormalization

1NF1NF All key attributes definedAll key attributes defined No repeating groups in a tableNo repeating groups in a table All attributes dependent on a primary All attributes dependent on a primary

keykey

Page 12: Normalization - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Explain the concept of table design  Explain unnormalized design and the first

1212

NormalizationNormalization

DependenciesDependencies Dependencies can be identifiedDependencies can be identified

functional dependency (functional dependency (desirable dependencies) desirable dependencies) based on primary keybased on primary key

Less desirable dependenciesLess desirable dependencies partialpartial

- based on part of composite primary key- based on part of composite primary key transitivetransitive

- one nonprime attribute depends on anther - one nonprime attribute depends on anther nonprime attributenonprime attribute

Page 13: Normalization - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Explain the concept of table design  Explain unnormalized design and the first

1313

Sequence SummarySequence Summary Repeating group: is a set of one or more Repeating group: is a set of one or more

fields that can occur any number of times in a fields that can occur any number of times in a single record, with each occurrence having single record, with each occurrence having different valuesdifferent values

An unnormalized record is one that contains a An unnormalized record is one that contains a repeating grouprepeating group

Normalization is a process for avoiding Normalization is a process for avoiding problems in data designproblems in data design

A table is in first normal form (1NF) if it does A table is in first normal form (1NF) if it does not contain a repeating groupnot contain a repeating group

To convert, you must expand the table’s To convert, you must expand the table’s primary key to include the primary key of the primary key to include the primary key of the repeating grouprepeating group

Page 14: Normalization - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Explain the concept of table design  Explain unnormalized design and the first

1414

Sequence SummarySequence Summary

In this Sequence we haveIn this Sequence we have Defined the term normalization Defined the term normalization Explained table designExplained table design Defined the standard notation formatDefined the standard notation format Defined and discussed the repeating Defined and discussed the repeating

groups and unnormalized designgroups and unnormalized design Explained the first normal form (1NF)Explained the first normal form (1NF) Explained the different types of Explained the different types of

attributes dependenciesattributes dependencies

Page 15: Normalization - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Explain the concept of table design  Explain unnormalized design and the first

1515

ReferenceReference

[1] System Analysis and Design, Sixth [1] System Analysis and Design, Sixth EditionEdition

Authors: Gary B. Shelly, Thomas J. Authors: Gary B. Shelly, Thomas J. Cashman and Harry J. Rosenblatt Cashman and Harry J. Rosenblatt

Publisher: SHELLY CASHMAN Publisher: SHELLY CASHMAN SEWIES.SEWIES.