Chapter 4 The Relational Model and Normalization.
-
Upload
juniper-stafford -
Category
Documents
-
view
247 -
download
5
Transcript of Chapter 4 The Relational Model and Normalization.
![Page 1: Chapter 4 The Relational Model and Normalization.](https://reader035.fdocuments.us/reader035/viewer/2022081504/56649eb55503460f94bbe38b/html5/thumbnails/1.jpg)
Chapter 4The Relational Model and
Normalization
![Page 2: Chapter 4 The Relational Model and Normalization.](https://reader035.fdocuments.us/reader035/viewer/2022081504/56649eb55503460f94bbe38b/html5/thumbnails/2.jpg)
Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke
2
Relations Relational DBMS products store data in the form of relations, a special
type of table A relation is a two-dimensional table that has the following
characteristics• Rows contain data about an entity• Columns contain data about attributes of the entity• All entries in a column are of the same kind• Each column has a unique name• Cells of the table hold a single value• The order of the columns is unimportant• The order of the rows is unimportant• No two rows may be identical
Although not all tables are relations, the terms table and relation are normally used interchangeably• Table/row/column = file/record/field = relation/tuple/attribute
![Page 3: Chapter 4 The Relational Model and Normalization.](https://reader035.fdocuments.us/reader035/viewer/2022081504/56649eb55503460f94bbe38b/html5/thumbnails/3.jpg)
Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke
3
Example: Relation
![Page 4: Chapter 4 The Relational Model and Normalization.](https://reader035.fdocuments.us/reader035/viewer/2022081504/56649eb55503460f94bbe38b/html5/thumbnails/4.jpg)
Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke
4
Example: Tables Not Relations
![Page 5: Chapter 4 The Relational Model and Normalization.](https://reader035.fdocuments.us/reader035/viewer/2022081504/56649eb55503460f94bbe38b/html5/thumbnails/5.jpg)
Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke
5
Functional Dependencies A functional dependency occurs when the value of one (set
of) attribute(s) determines the value of a second (set of) attribute(s)
The attribute on the left side of the functional dependency is called the determinant• SID GPA• SKU Department, SKU_Description• (CustomerNumber, ItemNumber, Quantity) Price
Mathematically, we say that “A” determines “B”, A B – Physically, we might say that “A” is a unique identifier for
“B”
![Page 6: Chapter 4 The Relational Model and Normalization.](https://reader035.fdocuments.us/reader035/viewer/2022081504/56649eb55503460f94bbe38b/html5/thumbnails/6.jpg)
Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke
Functional Dependency (2)
Full Functional Dependency: “B” is functionally dependent on “A” but not on any subset of “A”
• Transitive Dependency: If “B” and “C” are both dependent on “A”, but “C” is also dependent on “B”, we say that “C” is transitively dependent on “B”
6
![Page 7: Chapter 4 The Relational Model and Normalization.](https://reader035.fdocuments.us/reader035/viewer/2022081504/56649eb55503460f94bbe38b/html5/thumbnails/7.jpg)
Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke
7
Normalization
Normalization eliminates modification anomalies• Deletion anomaly: deletion of a row loses information
about two or more entities• Insertion anomaly: insertion of a fact in one entity
cannot be done until a fact about another entity is added Anomalies can be removed by splitting the relation
into two or more relations; each with a different, single theme
Normalization works through classes of relations called normal forms
![Page 8: Chapter 4 The Relational Model and Normalization.](https://reader035.fdocuments.us/reader035/viewer/2022081504/56649eb55503460f94bbe38b/html5/thumbnails/8.jpg)
Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke
8
Relationship of Normal Forms
![Page 9: Chapter 4 The Relational Model and Normalization.](https://reader035.fdocuments.us/reader035/viewer/2022081504/56649eb55503460f94bbe38b/html5/thumbnails/9.jpg)
Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke
9
Normal Forms Any table of data is in 1NF if it meets the
definition of a relation A relation is in 2NF if all its non-key attributes are
dependent on all of the key (no partial dependencies)• If a relation has a single attribute key, it is
automatically in 2NF A relation is in 3NF if it is in 2NF and has no
transitive dependencies A relation is in BCNF if every determinant is a
candidate key A relation is in fourth normal form if it is in BCNF
and has no multi-value dependencies
![Page 10: Chapter 4 The Relational Model and Normalization.](https://reader035.fdocuments.us/reader035/viewer/2022081504/56649eb55503460f94bbe38b/html5/thumbnails/10.jpg)
Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke
10
Example: 2NF
![Page 11: Chapter 4 The Relational Model and Normalization.](https://reader035.fdocuments.us/reader035/viewer/2022081504/56649eb55503460f94bbe38b/html5/thumbnails/11.jpg)
Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke
11
Example: NOT IN 3NF
![Page 12: Chapter 4 The Relational Model and Normalization.](https://reader035.fdocuments.us/reader035/viewer/2022081504/56649eb55503460f94bbe38b/html5/thumbnails/12.jpg)
Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke
12
Example: 3NF
![Page 13: Chapter 4 The Relational Model and Normalization.](https://reader035.fdocuments.us/reader035/viewer/2022081504/56649eb55503460f94bbe38b/html5/thumbnails/13.jpg)
Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke
13
Example: NOT IN BCNF
![Page 14: Chapter 4 The Relational Model and Normalization.](https://reader035.fdocuments.us/reader035/viewer/2022081504/56649eb55503460f94bbe38b/html5/thumbnails/14.jpg)
Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke
14
Example: BCNF
![Page 15: Chapter 4 The Relational Model and Normalization.](https://reader035.fdocuments.us/reader035/viewer/2022081504/56649eb55503460f94bbe38b/html5/thumbnails/15.jpg)
Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke
15
Another Example: NOT IN BCNF
CUSTOMER ID Tool Type Tool trainer ID
CUSTOMER ID + Tool Type Tool Trainer IDCUSTOMER ID + Tool TRAINER ID is also an candidate key (unique)Tool TRAINER ID Tool Type
Specialized tool maker
CUSTOMER ID Tool trainer ID Tool Type Tool trainer ID
![Page 16: Chapter 4 The Relational Model and Normalization.](https://reader035.fdocuments.us/reader035/viewer/2022081504/56649eb55503460f94bbe38b/html5/thumbnails/16.jpg)
Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke
16
Example: NOT IN 4NF
![Page 17: Chapter 4 The Relational Model and Normalization.](https://reader035.fdocuments.us/reader035/viewer/2022081504/56649eb55503460f94bbe38b/html5/thumbnails/17.jpg)
Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke
17
Example: 4NF
![Page 18: Chapter 4 The Relational Model and Normalization.](https://reader035.fdocuments.us/reader035/viewer/2022081504/56649eb55503460f94bbe38b/html5/thumbnails/18.jpg)
Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke
18
Example: 4NFCUSTOMER ID Tool Types Favorite Sports
CUSTOMER ID Tool Types
CUSTOMER ID Favorite Sports
![Page 19: Chapter 4 The Relational Model and Normalization.](https://reader035.fdocuments.us/reader035/viewer/2022081504/56649eb55503460f94bbe38b/html5/thumbnails/19.jpg)
Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke
19
DK/NF
First published in 1981 by Fagin DK/NF has no modification anomalies;
so no higher normal form is needed A relation is in DK/NF if every constraint on the
relation is a logical consequence of the definition of keys and domains
![Page 20: Chapter 4 The Relational Model and Normalization.](https://reader035.fdocuments.us/reader035/viewer/2022081504/56649eb55503460f94bbe38b/html5/thumbnails/20.jpg)
Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke
20
Example 1: DK/NF
![Page 21: Chapter 4 The Relational Model and Normalization.](https://reader035.fdocuments.us/reader035/viewer/2022081504/56649eb55503460f94bbe38b/html5/thumbnails/21.jpg)
Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke
21
Example: DK/NF
![Page 22: Chapter 4 The Relational Model and Normalization.](https://reader035.fdocuments.us/reader035/viewer/2022081504/56649eb55503460f94bbe38b/html5/thumbnails/22.jpg)
Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke
22
Normal Forms-Review Any table of data is in 1NF if it meets the
definition of a relation A relation is in 2NF if all its non-key attributes are
dependent on all of the key (no partial dependencies)• If a relation has a single attribute key, it is
automatically in 2NF A relation is in 3NF if it is in 2NF and has no
transitive dependencies A relation is in BCNF if every determinant is a
candidate key A relation is in fourth normal form if it is in BCNF
and has no multi-value dependencies
![Page 23: Chapter 4 The Relational Model and Normalization.](https://reader035.fdocuments.us/reader035/viewer/2022081504/56649eb55503460f94bbe38b/html5/thumbnails/23.jpg)
Database Processing: Fundamentals, Design and Implementation, 9/e by David M. Kroenke
23
De-normalized Designs When a normalized design is unnatural, awkward,
or results in unacceptable performance, a de-normalized design is preferred
Example • Normalized relation
CUSTOMER (CustNumber, CustName, Zip) CODES (Zip, City, State)
• De-Normalized relations CUSTOMER (CustNumber, CustName, City, State, Zip)