unit4 normalization

27
F3803 – DATABASE SYSTEM UNIT 4 RELATIONAL DATABASE NORMALIZATION

Upload: mohd-firhan-jasni

Post on 19-Jun-2015

79 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: UNIT4 Normalization

F3803 – DATABASE SYSTEM

UNIT 4

RELATIONAL DATABASENORMALIZATION

Page 2: UNIT4 Normalization

Relational Data Model

•A two-dimensional table with columns and rows is called a RELATION

What is Relation?

Page 3: UNIT4 Normalization

Skema Hubungan

Skema hubungan adalah senarai atribut yang terkandung dalam hubungan tersebut

Format : Nama_relation (Kunci Primer, Atribut Bukan Kunci)

Page 4: UNIT4 Normalization

• Nama relation : PUBLISHER• Kunci Primer : Publisher_Code• Atribut Bukan Kunci : Name, City

PUBLISHER (Publisher_Code, Name, City)

Page 5: UNIT4 Normalization

prepared by: [email protected]

Page 6: UNIT4 Normalization

• AUTHOR (Author_No, Author_Name)• BOOK_AUTHOR (Book_Code, Author_No)• BOOK (Book_Code, Book_Title, , Description,

Type, Price, Book_Sample, Book_Cover, Publisher_Code)y)

Page 7: UNIT4 Normalization

C# and P# is a primary key for CUSTOMER and PRODUCT.While the others is non-primary key.

Page 8: UNIT4 Normalization

Problem in Relational Data Model

Information Redundancy

Anomalies

Page 9: UNIT4 Normalization

• Anomali Pengemaskinian (Update Anomalies)• Anomali - Ralat yang mungkin berlaku apabila pengguna ingin mengemas

kini jadual (relation / table) yang mengandungi data yang berulang.

(a) Jenis-jenis Anomali: i) Anomali Pengubahsuaian(ii) Anomali penambahan (iii) Anomali penghapusan

(b)Pertindanan Maklumat (Information Redundancy)• Maklumat yang berulang yang disebabkan oleh penyimpanan data yang

sama beberapa kali.

Page 10: UNIT4 Normalization

Anomalies

• Errors or inconsistence that may result when a user attempts to update a table that contains redundant data

• 3 types of anomalies ( modification, insert & delete )Anomalies

• Duplication of data due to storing the same data multiple timesInformation

Redundancy

Page 11: UNIT4 Normalization

Update/Modification Anomalies

Update

• The modification anomaly occurs when the record is updated in the relation. In this anomaly, the modification in the value of specific attribute requires modification in all records in which that value occurs.

Page 12: UNIT4 Normalization
Page 13: UNIT4 Normalization

prepared by: [email protected]

Page 14: UNIT4 Normalization

Insert Anomalies

Insert

• The insertion anomaly occurs when a new record is inserted in the relation. In this anomaly, the user cannot insert a fact about an entity until he has an additional fact about another entity.

Page 15: UNIT4 Normalization
Page 16: UNIT4 Normalization

prepared by: [email protected]

Page 17: UNIT4 Normalization

Delete Anomalies

•The deletion anomaly occurs when a record is deleted from the relation. In this anomaly, the deletion of facts about an entity automatically deleted the fact of another entity

Delete

Page 18: UNIT4 Normalization
Page 19: UNIT4 Normalization

prepared by: [email protected]

Page 20: UNIT4 Normalization
Page 21: UNIT4 Normalization
Page 22: UNIT4 Normalization

Normalization

A process for assigning attributes into a table and reduces data

redundancy and helps eliminate the data anomalies that associated

with poor database design (un-normalized)

Page 23: UNIT4 Normalization

• Penormalan (Normalisation)• Satu proses untuk menempatkan atribut ke dalam

jadual bagi mengelakkan masalah anomali dan pertindanan data yang akan menyebabkan pangkalan data yang tidak stabil (Unnormalised).

• Jadual Unnormalised (Unnormalised Form (UNF))• Jadual yang mengandungi satu atau lebih kumpulan

data yang berulang

Page 24: UNIT4 Normalization

The purposes of normalization

To ensure that the anomalies doesn’t occur

To reduce data or storage redundancy

To ensure easy for record searching/finding

Page 25: UNIT4 Normalization

Steps in Normalization

UNF 1NF 2NF 3NF

Remove repeating groups

Identify functional dependencies

Remove transitive dependencies

Page 26: UNIT4 Normalization

Func

tiona

l D

epen

denc

ies Functional dependencies describe

relationships between attributes in a relationA relationship between attributes in which one attribute or group of attribute determines the value of another in the same table

Page 27: UNIT4 Normalization

Tran

sitiv

e D

epen

denc

ies A Functional dependency between 2 or more

non-key attributesA condition in which an attribute is dependent on another attributes that is not part of the primary keyA relation is in 3NF if it is in 2NF and has no transitive dependenciesNon-primary key attribute is functionally dependent on another non-primary key attribute