chapter 2 the relational database model
DESCRIPTION
Chapter 2 The Relational Database Model. Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel. A Logical View of Data. Relational database model’s structural and data independence enables us to view data logically rather than physically . - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/1.jpg)
22Chapter 2The Relational Database Model
Database Systems: Design, Implementation, and Management 4th Edition
Peter Rob & Carlos Coronel
![Page 2: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/2.jpg)
22
A Logical View of DataA Logical View of Data
Relational database model’s structural and data independence enables us to view data logically rather than physically.
The logical view allows a simpler file concept of data storage.
The use of logically independent tables is easier to understand.
Logical simplicity yields simpler and more effective database design methodologies.
![Page 3: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/3.jpg)
22
A Logical View of DataA Logical View of Data Entities and Attributes
An entity is a person, place, event, or thing for which we intend to collect data.
University -- Students, Faculty Members, Courses Airlines -- Pilots, Aircraft, Routes, Suppliers
Each entity has certain characteristics known as attributes.
Student -- Student Number, Name, GPA, Date of Enrollment, Data of Birth, Home Address, Phone Number, Major
Aircraft -- Aircraft Number, Date of Last Maintenance, Total Hours Flown, Hours Flown since Last Maintenance
![Page 4: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/4.jpg)
22
A Logical View of DataA Logical View of Data Entities and Attributes
A grouping of related entities becomes an entity set.
The STUDENT entity set contains all student entities.
The FACULTY entity set contains all faculty entities.
The AIRCRAFT entity set contains all aircraft entities.
![Page 5: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/5.jpg)
22
A Logical View of DataA Logical View of Data Tables and Their Characteristics
A table contains a group of related entities -- i.e. an entity set.
The terms entity set and table are often used interchangeably.
A table is also called a relation.
![Page 6: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/6.jpg)
22
Summary of the Characteristics of a Relational Table
Table 2.1
![Page 7: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/7.jpg)
22
A Listing of the STUDENT Table Attribute Values
Figure 2.1
![Page 8: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/8.jpg)
22
KeysKeys Controlled redundancy (shared common
attributes) makes the relational database work.
The primary key of one table appears again as the link (foreign key) in another table.
If the foreign key contains either matching values or nulls, the table(s) that make use of such a foreign key are said to exhibit referential integrity.
![Page 9: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/9.jpg)
22
Figure 2.2 An Example of a Simple Relational Database
![Page 10: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/10.jpg)
22
The Relational Schema for the CH2_SALE_CO Database
Figure 2.3
![Page 11: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/11.jpg)
22
KeysKeys A key helps define entity relationships.
The key’s role is based on a concept known as determination, which is used in the definition of functional dependence.
The attribute B is functionally dependent on A if A determines B.
An attribute that is part of a key is known as a key attribute.
A multi-attribute key is known as a composite key.
If the attribute (B) is functionally dependent on a composite key (A) but not on any subset of that composite key, the attribute (B) is fully functionally dependent on (A).
![Page 12: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/12.jpg)
22
Table 2.2
Student Classification
![Page 13: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/13.jpg)
22
Relational Database Keys
Table 2.3
![Page 14: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/14.jpg)
22
Integrity Rules Revisited
Table 2.4
![Page 15: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/15.jpg)
22
Figure 2.4 An Illustration of Integrity Rules
![Page 16: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/16.jpg)
22
Relational Database OperatorsRelational Database Operators
The degree of relational completeness can be defined by the extent to which relational algebra is supported.
Relational algebra defines the theoretical way of manipulating table contents using the eight relational functions: SELECT, PROJECT, JOIN, INTERSECT, UNION, DIFFERENCE, PRODUCT, and DIVIDE.
![Page 17: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/17.jpg)
22
Relational Database OperatorsRelational Database Operators UNION combines all rows from two tables.
The two tables must be union compatible.
Figure 2.5 UNION
![Page 18: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/18.jpg)
22
Relational Database OperatorsRelational Database Operators INTERSECT produces a listing that contains
only the rows that appear in both tables. The two tables must be union compatible.
Figure 2.6 INTERSECT
![Page 19: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/19.jpg)
22
Relational Database OperatorsRelational Database Operators DIFFERENCE yields all rows in one table
that are not found in the other table; i.e., it subtracts one table from the other. The tables must be union compatible.
Figure 2.7 DIFFERENCE
![Page 20: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/20.jpg)
22
Relational Database OperatorsRelational Database Operators PRODUCT produces a list of all possible
pairs of rows from two tables.
Figure 2.8 PRODUCT
![Page 21: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/21.jpg)
22
Relational Database OperatorsRelational Database Operators SELECT yields values for all attributes found in
a table. It yields a horizontal subset of a table.
![Page 22: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/22.jpg)
22
Relational Database OperatorsRelational Database Operators PROJECT produces a list of all values for selected
attributes. It yields a vertical subset of a table.
![Page 23: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/23.jpg)
22
Relational Database OperatorsRelational Database Operators JOIN allows us to combine information from
two or more tables. JOIN is the real power behind the relational database, allowing the use of independent tables linked by common attributes.
![Page 24: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/24.jpg)
22
Relational Database OperatorsRelational Database Operators Natural JOIN links tables by selecting
only the rows with common values in their common attribute(s). It is the result of a three-stage process:
A PRODUCT of the tables is created. (Figure 2.12)
A SELECT is performed on the output of the first step to yield only the rows for which the common attribute values match. (Figure 2.13)
A PROJECT is performed to yield a single copy of each attribute, thereby eliminating the duplicate column. (Figure 2.14)
![Page 25: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/25.jpg)
22
Natural Join, Step 1: PRODUCT
Figure 2.12
![Page 26: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/26.jpg)
22
Figure 2.13 Natural Join, Step 2: SELECT
Figure 2.14 Natural Join, Step 3: PROJECT
![Page 27: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/27.jpg)
22
Relational Database OperatorsRelational Database Operators EquiJOIN links tables based on an equality
condition that compares specified columns of each table. The outcome of the EquiJOIN does not eliminate duplicate columns and the condition or criteria to join the tables must be explicitly defined.
Theta JOIN is an equiJOIN that compares specified columns of each table using a comparison operator other than the equality comparison operator.
In an Outer JOIN, the unmatched pairs would be retained and the values for the unmatched other tables would be left blank or null.
![Page 28: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/28.jpg)
22
Outer JOIN
Figure 2.15
![Page 29: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/29.jpg)
22
Relational Database OperatorsRelational Database Operators DIVIDE requires the use of one single-
column table and one two-column table.
Figure 2.16 DIVIDE
![Page 30: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/30.jpg)
22
The Data Dictionary and the System Catalog
The Data Dictionary and the System Catalog
Data dictionary contains metadata to provide detailed accounting of all tables within the database.
System catalog is a very detailed system data dictionary that describes all objects within the database.
System catalog is a system-created database whose tables store the database characteristics and contents.
System catalog tables can be queried just like any other tables.
System catalog automatically produces database documentation.
![Page 31: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/31.jpg)
22
A Sample Data Dictionary
Table 2.6
![Page 32: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/32.jpg)
22
Relationships within the Relational Database
Relationships within the Relational Database
E-R Diagram (ERD)
Rectangles are used to represent entities.
Entity names are nouns and capitalized.
Diamonds are used to represent the relationship(s) between the entities.
The number 1 is used to represent the “1” side of the relationship.
The letter M is used to represent the “many” sides of the relationship.
![Page 33: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/33.jpg)
22
The Relationship Between Painter and Painting
Figure 2.17
![Page 34: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/34.jpg)
22
An Alternate Way to Present the RelationshipBetween Painter and Painting
Figure 2.18
![Page 35: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/35.jpg)
22
A 1:M Relationship: The CH2_MUSEUM Database
Figure 2.19
![Page 36: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/36.jpg)
22
The 1:M Relationship Between Course and Class
Figure 2.20
![Page 37: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/37.jpg)
22
![Page 38: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/38.jpg)
22
The M:N Relationship Between Student and Class
Figure 2.22
![Page 39: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/39.jpg)
22
Table 2.7
Sample Student Enrollment Data
![Page 40: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/40.jpg)
22
A Many-to-Many Relationship Between Student and Class
Figure 2.23
![Page 41: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/41.jpg)
22
![Page 42: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/42.jpg)
22
Changing the M:N Relationship to Two 1:M Relationships
Figure 2.25
![Page 43: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/43.jpg)
22
The Expanded Entity Relationship Model
Figure 2.26
![Page 44: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/44.jpg)
22
The Relational Schema for the Entity Relationship Diagram in Figure 2.26
Figure 2.27
![Page 45: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/45.jpg)
22
Data Redundancy RevisitedData Redundancy Revisited Proper use of foreign keys is crucial to
exercising data redundancy control.
Database designers must reconcile three often contradictory requirements: design elegance, processing speed, and information requirements. (Chapter 4)
Proper data warehousing design even requires carefully defined and controlled data redundancies, to function properly. (Chapter 13)
![Page 46: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/46.jpg)
22 Figure 2.28A Small Invoicing System
![Page 47: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/47.jpg)
22The redundancy is crucial to the system’s success. Copying the product price from the PRODUCT table to the LINE table means that it is possible to maintain the historical accuracy of the transactions.
Figure 2.29The Relational Schema for the Invoicing System in Figure 2.28
![Page 48: Chapter 2 The Relational Database Model](https://reader033.vdocument.in/reader033/viewer/2022061609/56813066550346895d963fc5/html5/thumbnails/48.jpg)
22
IndexesIndexes An index is composed of an index key and a
set of pointers.
Figure 2.30 Components of an Index