![Page 1: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/1.jpg)
Chapter 4Chapter 4Normalization of Normalization of Database TablesDatabase Tables
![Page 2: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/2.jpg)
2
Database Tables and Database Tables and NormalizationNormalization
Table is basic building block in database Table is basic building block in database designdesign
Table’s structure is of great interestTable’s structure is of great interest Two cases:Two cases:
possible poor table structures in good database possible poor table structures in good database designdesign
Modify existing database with existing poor table Modify existing database with existing poor table structurestructure
Normalization can help recognize a poor table Normalization can help recognize a poor table and convert to good tables with good structureand convert to good tables with good structure
![Page 3: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/3.jpg)
3
Database Tables and Database Tables and NormalizationNormalization
Normalization is process for Normalization is process for assigning attributes to entitiesassigning attributes to entities Reduces data redundanciesReduces data redundancies Expending entitiesExpending entities Helps eliminate data anomaliesHelps eliminate data anomalies Produces controlled redundancies to Produces controlled redundancies to
link tableslink tables Cost more processing effortsCost more processing efforts Series steps called normal formsSeries steps called normal forms
![Page 4: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/4.jpg)
4
Database Tables and Database Tables and NormalizationNormalization
Normalization stagesNormalization stages 1NF - First normal form1NF - First normal form 2NF - Second normal form2NF - Second normal form 3NF - Third normal form3NF - Third normal form 4NF - Fourth normal form4NF - Fourth normal form
Better in dependency
Worse in performance (I/O)
Business
BioinformaticsStatistical data
![Page 5: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/5.jpg)
5
Database Tables and Database Tables and NormalizationNormalization
Example: construction companyExample: construction company Building projectsBuilding projects
Project numberProject number Project nameProject name Employees assignedEmployees assigned ……
EmployeeEmployee Employee numberEmployee number Employee nameEmployee name Job classificationJob classification
![Page 6: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/6.jpg)
6
Table 4.1 should be here.
![Page 7: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/7.jpg)
7
Figure 4.1 ObservationsFigure 4.1 Observations
PRO_NUM intended to be primary PRO_NUM intended to be primary key, but it contains null values.key, but it contains null values.
Table entries invite data Table entries invite data inconsistenciesinconsistencies
![Page 8: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/8.jpg)
8
Figure 4.1 ObservationsFigure 4.1 Observations Table displays data redundancies Table displays data redundancies
which yield the following anomalieswhich yield the following anomalies UpdateUpdate
Modifying JOB_CLASSModifying JOB_CLASS InsertionInsertion
New employee must be assigned project New employee must be assigned project (phantom project)(phantom project)
DeletionDeletion If employee deleted, other vital data lostIf employee deleted, other vital data lost
![Page 9: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/9.jpg)
9
Figure 4.2 is insert here.
Repeating group (any project can have a group of data entries) which should not to be appeared in relational table
![Page 10: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/10.jpg)
10
Data Organization: 1NFData Organization: 1NF
Figure 4.3
PK PK
![Page 11: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/11.jpg)
11
Conversion to 1NFConversion to 1NF
Repeating groups must be Repeating groups must be eliminatedeliminated Proper primary key developedProper primary key developed
Uniquely identifies attribute values (rows)Uniquely identifies attribute values (rows) Combination of PROJ_NUM and Combination of PROJ_NUM and
EMP_NUMEMP_NUM
![Page 12: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/12.jpg)
12
Conversion to 1NFConversion to 1NF Repeating groups must be eliminatedRepeating groups must be eliminated
Dependencies can be identifiedDependencies can be identified
A particular relationship between two A particular relationship between two attributes. For a given relation, attribute B is attributes. For a given relation, attribute B is functionally dependent on attribute A if, for functionally dependent on attribute A if, for every valid value of A, that value of A uniquely every valid value of A, that value of A uniquely determines the value of B. determines the value of B.
A functional dependency exists when the value A functional dependency exists when the value of one thing is fully determined by another. For of one thing is fully determined by another. For example, given the relation EMP(empNo, example, given the relation EMP(empNo, empName, sal), attribute empName is empName, sal), attribute empName is functionally dependant on attribute empNo. If functionally dependant on attribute empNo. If we know empNo, we also know the empName. we know empNo, we also know the empName.
![Page 13: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/13.jpg)
13
Desirable dependencies based on Desirable dependencies based on primary keyprimary keyLess desirable dependenciesLess desirable dependencies
Partial Partial based on part of composite based on part of composite primary keyprimary key
Transitive Transitive one nonprime attribute one nonprime attribute depends ondepends on another nonprime attribute another nonprime attribute
![Page 14: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/14.jpg)
14
Dependency Diagram Dependency Diagram (1NF)(1NF)
Figure 4.4
Above: Desired Dependencies
Below: Less Desired DependenciesComposite primary key
![Page 15: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/15.jpg)
15
PROJ_NUM,EMP_NUM PROJ_NAME, EMP_NAME, JOB_CLASS,CHG_HOUR, HOURS
PROJ_NUM PROJ_NAME
DESIRED DEPENDENCIES
EMP_NUM EMP_NAME, JOB_CLASS, CHG_HOUR
PARTIAL DEPENDENCIES
JOB_CLASS -> CHG_HOUR TRANSITIVE DEPENDENCIES
![Page 16: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/16.jpg)
16
1NF Summarized1NF Summarized
All key attributes definedAll key attributes defined No repeating groups in tableNo repeating groups in table All attributes dependent on All attributes dependent on
primary keyprimary key
![Page 17: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/17.jpg)
17
Conversion to 2NFConversion to 2NF
Start with 1NF format:Start with 1NF format: Write each key component on Write each key component on
separate lineseparate line Write original key on last lineWrite original key on last line Each component is new tableEach component is new table Write dependent attributes after Write dependent attributes after
each keyeach keyPROJECT (PROJ_NUM, PROJ_NAME)EMPLOYEE (EMP_NUM, EMP_NAME, JOB_CLASS, CHG_HOUR)ASSIGN (PROJ_NUM, EMP_NUM, HOURS)
![Page 18: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/18.jpg)
18
2NF Conversion Results2NF Conversion ResultsFigure 4.5
![Page 19: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/19.jpg)
19
2NF Summarized2NF Summarized
In 1NFIn 1NF Includes no partial dependenciesIncludes no partial dependencies
No attribute dependent on a portion No attribute dependent on a portion of primary keyof primary key
Still possible to exhibit transitive Still possible to exhibit transitive dependencydependency Attributes may be functionally Attributes may be functionally
dependent on nonkey attributesdependent on nonkey attributes
![Page 20: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/20.jpg)
20
Conversion to 3NFConversion to 3NF
Create separate table(s) to eliminate Create separate table(s) to eliminate transitive functional dependencies transitive functional dependencies
PROJECT (PROJ_NUM, PROJ_NAME)ASSIGN (PROJ_NUM, EMP_NUM, HOURS)EMPLOYEE (EMP_NUM, EMP_NAME, JOB_CLASS)JOB (JOB_CLASS, CHG_HOUR)
![Page 21: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/21.jpg)
21
3NF Summarized3NF Summarized
In 2NFIn 2NF Contains no transitive Contains no transitive
dependenciesdependencies
![Page 22: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/22.jpg)
22
Additional DB Additional DB EnhancementsEnhancements
Figure 4.6
![Page 23: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/23.jpg)
23
![Page 24: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/24.jpg)
24
Boyce-Codd Normal Boyce-Codd Normal Form (BCNF)Form (BCNF)
Every determinant in the table is a Every determinant in the table is a candidate keycandidate key Determinant is attribute whose value Determinant is attribute whose value
determines other values in rowdetermines other values in row 3NF table with one candidate key is 3NF table with one candidate key is
already in BCNFalready in BCNF
![Page 25: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/25.jpg)
25
3NF Table Not in BCNF3NF Table Not in BCNF
Figure 4.7
![Page 26: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/26.jpg)
26
Decomposition of Table Decomposition of Table
Structure to Meet Structure to Meet BCNFBCNF
Figure 4.8
![Page 27: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/27.jpg)
27
Example: BCNF Example: BCNF conversionconversion
![Page 28: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/28.jpg)
28
Decomposition into Decomposition into BCNFBCNF
Figure 4.9
![Page 29: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/29.jpg)
29
Normalization and Normalization and Database DesignDatabase Design
Normalization should be part of the Normalization should be part of the design processdesign process
Make sure the proposed entities meet Make sure the proposed entities meet the required normal form before the the required normal form before the table structures are createdtable structures are created
Used to redesign or modify the Used to redesign or modify the existing table structures.existing table structures.
E-R Diagram provides macro viewE-R Diagram provides macro view
![Page 30: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/30.jpg)
30
Normalization and Normalization and Database DesignDatabase Design
Normalization provides micro view Normalization provides micro view of entitiesof entities Focuses on characteristics of specific Focuses on characteristics of specific
entitiesentities May yield additional entitiesMay yield additional entities
Difficult to separate normalization Difficult to separate normalization from E-R diagrammingfrom E-R diagramming
Business rules must be determinedBusiness rules must be determined
![Page 31: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/31.jpg)
31
Normalization and Normalization and Database DesignDatabase Design
Contracting company’s example:Contracting company’s example:
PROJECT (PROJ_NUM, PROJ_NAME)EMPLOYEE(EMP_NUM, EMP_LNAME,EMP_FNAME,EMP_INITAL, JOB_DESCRIPTION, JOB_CHG_HOUR);
![Page 32: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/32.jpg)
32
Initial ERD for Initial ERD for Contracting CompanyContracting Company
Figure 4.10
Already 3NFThere is a transitive dependency
![Page 33: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/33.jpg)
33
PROJECT (PROJ_NUM, PROJ_NAME)EMPLOYEE(EMP_NUM, EMP_LNAME,EMP_FNAME,EMP_INITAL, JOB_CODE)
JOB (JOB_CODE, JOB_DESCRIPTION, JOB_CHG_HOUR);
Removal
![Page 34: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/34.jpg)
34
Modified ERD for Modified ERD for Contracting CompanyContracting Company
Figure 4.11
![Page 35: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/35.jpg)
35
Final ERD for Final ERD for Contracting CompanyContracting Company
Figure 4.12
(M:N) converting to (1:M)
![Page 36: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/36.jpg)
36
PROJECT (PROJ_NUM, PROJ_NAME, EMP_NUM)
EMPLOYEE(EMP_NUM, EMP_LNAME,EMP_FNAME,EMP_INITAL, EMP_HIREDATE, JOB_CODE)
JOB (JOB_CODE,, JOB_DESCRIPTION, JOB_CHG_HOUR);
ASSIGN((ASSIGN_NUM, ASSIGN_DATE, ASSIGN_HOURS, ASSIGN_CHG_HOURS, ASSIGN_CHARGE, EMP_NUM, PROJ_JUM)
![Page 37: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/37.jpg)
37
![Page 38: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/38.jpg)
38
DenormalizationDenormalization Normalization is one of many Normalization is one of many
database design goals database design goals Normalized table requirementsNormalized table requirements
Additional processingAdditional processing Loss of system speedLoss of system speed
![Page 39: Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building](https://reader035.vdocuments.mx/reader035/viewer/2022081420/5697bf701a28abf838c7da2a/html5/thumbnails/39.jpg)
39
DenormalizationDenormalization
Normalization purity is difficult to Normalization purity is difficult to sustain due to conflict in:sustain due to conflict in: Design efficiencyDesign efficiency Information requirementsInformation requirements Processing Processing