database design (normalizations) dco11310 database systems and design by rose chang
TRANSCRIPT
![Page 1: Database Design (Normalizations) DCO11310 Database Systems and Design By Rose Chang](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649eb55503460f94bbe406/html5/thumbnails/1.jpg)
Database Design (Normalizations)
DCO11310
Database Systems and Design
By Rose Chang
![Page 2: Database Design (Normalizations) DCO11310 Database Systems and Design By Rose Chang](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649eb55503460f94bbe406/html5/thumbnails/2.jpg)
Logical Data Model
1. Build a Conceptual Data Model2. Build and validate logical data model (LDM)
Drive relations for LDM Validate relations using normalisation Validate relations against user transactions Check integrity constraints Review LDM with user Merge LDMs into global model
![Page 3: Database Design (Normalizations) DCO11310 Database Systems and Design By Rose Chang](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649eb55503460f94bbe406/html5/thumbnails/3.jpg)
Top-down Modeling
Entity - Entity - Entity
DATABASE
Table - Table – Table - Table - Table
Attributes+
Constraints
Attributes+
Constraints
Attributes+
Constraints
Attributes+
Constraints
Attributes+
Constraints
![Page 4: Database Design (Normalizations) DCO11310 Database Systems and Design By Rose Chang](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649eb55503460f94bbe406/html5/thumbnails/4.jpg)
Bottom-up Modeling
Entity - Entity - Entity
DATABASE
Table - Table – Table - Table - Table
Attributes+
Constraints
Attributes+
Constraints
Attributes+
Constraints
Attributes+
Constraints
Attributes+
Constraints
![Page 5: Database Design (Normalizations) DCO11310 Database Systems and Design By Rose Chang](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649eb55503460f94bbe406/html5/thumbnails/5.jpg)
Normalizations
A process that assigns attributes to entities in such a way that data redundancies are reduced or eliminated
Enables us to analyse the design of the database Identify the existence of potential data anomalies result from
those redundancies A step to step process : given a data model and the relevant
FDs Decomposition of relation schema based on knowledge of
underlying functional dependencies Results in a relational schema that satisfies certain important criteria:
1NF, 2NF, 3NF, BCNF, 4NF, … E.G., No anomalies, no spurious or invalid data during joins
![Page 6: Database Design (Normalizations) DCO11310 Database Systems and Design By Rose Chang](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649eb55503460f94bbe406/html5/thumbnails/6.jpg)
Update Anomalies
Redundancies Information fact is stored in more than one place
Insertion anomalies Unable to insert a fact into table without having other facts (or
inserting nulls) Deletion anomalies
If a set of values becomes empty, we may lose other information as a side effect
Modification anomalies Change the information in one tuple but leave information
unchanged in another
![Page 7: Database Design (Normalizations) DCO11310 Database Systems and Design By Rose Chang](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649eb55503460f94bbe406/html5/thumbnails/7.jpg)
Example
Real bad design: Study(Sid,name,Dept,Course_code, Course_name)
Sid Name Dept C_code C_Name
S01 Rose DCO 20401 DB
S01 Rose DCO 30198 Project
S02 Peter DCO 20401 DB
S03 Mary DCO 30198 Project
S04 Tom DCO 20401 DB
![Page 8: Database Design (Normalizations) DCO11310 Database Systems and Design By Rose Chang](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649eb55503460f94bbe406/html5/thumbnails/8.jpg)
What are the Anomalies?
Redundancy Insertion Anomaly Deletion Anomaly What is the best design for this information?
No anomalies Can reconstruct all original information
![Page 9: Database Design (Normalizations) DCO11310 Database Systems and Design By Rose Chang](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649eb55503460f94bbe406/html5/thumbnails/9.jpg)
Process of Normalization
Users User’s requirement
Forms/ Report
Other sourcesFrom company
Data sources
UNFTransfer attributes into table format
1NFRemove repeating group
2NF
Remove partial dependencies
3NFRemove transitive dependencies
![Page 10: Database Design (Normalizations) DCO11310 Database Systems and Design By Rose Chang](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649eb55503460f94bbe406/html5/thumbnails/10.jpg)
Normalizations
Unnormalised Form (UNF) can be captured from data entities generated in System Analysis phase sample reports or screens
Invoice
Stf_name: Rose C W Chang Stf_ID. : 50121456Dept: Sales Dpt_Code: SAL
Item Code Item Description PriceI011 Wing-Type-A 70I012 Wing-Type-B 60I013 Engine-Type-A 70
Total 200
![Page 11: Database Design (Normalizations) DCO11310 Database Systems and Design By Rose Chang](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649eb55503460f94bbe406/html5/thumbnails/11.jpg)
First Normal Form
A relation is in first normal form (1NF) if and only if All the key attributes are defined There are no repeating groups in the table All non-primary-key attribute is functionally
dependent on the primary key Problem : attributes not necessary fully
functionally dependent
![Page 12: Database Design (Normalizations) DCO11310 Database Systems and Design By Rose Chang](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649eb55503460f94bbe406/html5/thumbnails/12.jpg)
Functional Dependencies
Attribute B is functionally dependent on attribute A if and only if each value of A is associated with precisely one value of B at any one time
E.G. Stf_name is functionally dependent on Stf_ID, Stf_ID Stf_name
The attribute on the left is a determinant
![Page 13: Database Design (Normalizations) DCO11310 Database Systems and Design By Rose Chang](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649eb55503460f94bbe406/html5/thumbnails/13.jpg)
First Normal Form (1NF)
Eliminate repeating groups of data items
UNF 1NFStf_ID Stf_IDStf_name Stf_nameDept_code Dept_codeDept_name Dept_name{Item_code Item_desc Stf_ID Price } Item_code Item_desc
Price
![Page 14: Database Design (Normalizations) DCO11310 Database Systems and Design By Rose Chang](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649eb55503460f94bbe406/html5/thumbnails/14.jpg)
Second Normal Form
A relation is in second normal form (2NF) if and only if It is in 1NF All non-primary-key attribute is fully
functionally dependent on the primary key, that is, there is no partial dependecy.
![Page 15: Database Design (Normalizations) DCO11310 Database Systems and Design By Rose Chang](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649eb55503460f94bbe406/html5/thumbnails/15.jpg)
Full Functional Dependency
Attribute B is fully functionally dependent (FD) on attribute A if it is functionally dependent on A and NOT functionally dependent on any subset of A
All determinants in each relation are candidate keys
![Page 16: Database Design (Normalizations) DCO11310 Database Systems and Design By Rose Chang](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649eb55503460f94bbe406/html5/thumbnails/16.jpg)
1NF 2NFStf_ID Stf_IDStf_name Stf_nameDept_code Dept_codeDept_name Dept_name
Stf_ID Stf_ID Item_codeItem_code Item_code Item_descItem_desc Price Price
Second Normal Form (2NF)
Record is in 1NF and no partly dependencies
![Page 17: Database Design (Normalizations) DCO11310 Database Systems and Design By Rose Chang](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649eb55503460f94bbe406/html5/thumbnails/17.jpg)
Third Normal Form
A relation is in third normal form (3NF) if and only if It is in 2NF It contains NO transitive dependencies
transitive dependencies A condition where A, B, and C are attributes of a relation
such that if AB and BC, then C is transitively dependent on A via B (provided that A is not FD on B or C)
![Page 18: Database Design (Normalizations) DCO11310 Database Systems and Design By Rose Chang](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649eb55503460f94bbe406/html5/thumbnails/18.jpg)
Third Normal Form (3NF)
Record is in 2NF and no transitive dependencies (no fields dependent on nonkey field(s))
2NF 3NFStf_ID Stf_ID Dept_codeStf_name Stf_name Dept_nameDept_code Dept_codeDept_name
Stf_ID Item_codeStf_ID Item_code Item_code Item_descItem_code Item_desc PricePrice
![Page 19: Database Design (Normalizations) DCO11310 Database Systems and Design By Rose Chang](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649eb55503460f94bbe406/html5/thumbnails/19.jpg)
E/R Model after Normalization
Staff Sold Items
ItemDept
![Page 20: Database Design (Normalizations) DCO11310 Database Systems and Design By Rose Chang](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649eb55503460f94bbe406/html5/thumbnails/20.jpg)
Normalize it to 3NF
Wellmeadows Hospital
Drug
Ward 11
Units per
Robert MacDonald
Orthopaedic
Name
10223 Morphine Pain Killer
Ward Number :
Ward Name :
Full Name :
P10034 Patient Number :
Patient Medication Form
84 Bed Number :
Dosage Description
10mg/ml 50
Number Day
Start
24/03/96
Date
Finish
24/04/96
Date
10334 Tetracyclene Antibiotic 0.5mg/ml 10 24/03/96 17/04/96
10223 Morphine Pain Killer 10mg/ml 10 25/04/96 02/05/96
Method
Admin
Oral
IV
Oral
of
![Page 21: Database Design (Normalizations) DCO11310 Database Systems and Design By Rose Chang](https://reader035.vdocuments.net/reader035/viewer/2022062422/56649eb55503460f94bbe406/html5/thumbnails/21.jpg)
Q & A
Readings:Connolly: Ch13, except BCNF, 4NF & 5NF