8/9/2019 Ch.8b Supplementary Note-relational Database
1/11
Supplement for non-ISM students
By Tony WONG
A Logical View of DataA Logical View of Data
Relational database models structural and
data independence enables us to view data
logically rather than physically.
The logical view allows a simpler file
.
The use of lo icall inde endent tables is
easier to understand.
og ca s mp c ty y e s s mp er an more
effective database design methodologies.
8/9/2019 Ch.8b Supplementary Note-relational Database
2/11
A Logical View of Data
Entities and Attributes
An entity is a person, place, event, or thing for which we intend
to collect data.n vers y -- u en s, acu y em ers, ourses
Airlines -- Pilots, Aircraft, Routes, Suppliers
Each entity has certain characteristics known as attributes.
Student -- Student Number, Name, GPA, Date of Enrollment,
, , ,
Aircraft -- Aircraft Number, Date of Last Maintenance, Total
Hours Flown, Hours Flown since Last Maintenance
A Logical View of Data
Entities and Attributes
A grouping of related entities becomes an entity set.
The STUDENT entity set contains all studententities.
The FACULTY entity set contains all faculty
entities.
The AIRCRAFT entity set contains all aircraft
entities.
8/9/2019 Ch.8b Supplementary Note-relational Database
3/11
A Logical View of DataA Logical View of Data
Tables and Their Characteristics
A table contains a group of related entities -- i.e. an.
The terms entity set and table are often used
n erc angea y.
A table is also called a relation.
Summary of the Characteristics of a Relational Table
8/9/2019 Ch.8b Supplementary Note-relational Database
4/11
A Listing of the STUDENT Table Attribute Values
KeysKeys
Primar Ke contains attribute s that can
uniquely identify one row in a table.
The primary key of one table appears again as the
.
Controlled redundancy (shared common
attributes) makes the relational database work.
8/9/2019 Ch.8b Supplementary Note-relational Database
5/11
Figure 2.2 An Example of a Simple Relational Database
The Relational Schema for the CH2_SALE_CO Database
8/9/2019 Ch.8b Supplementary Note-relational Database
6/11
Relational Database Keys
Relational Database OperatorsRelational Database Operators
Relational al ebra defines the theoretical
way of manipulating table contents using the
ei ht relational functions: SELECT,
PROJECT, JOIN, INTERSECT, UNION,DIFFERENCE, and PRODUCT.
8/9/2019 Ch.8b Supplementary Note-relational Database
7/11
Relational Database OperatorsRelational Database Operators
UNION combines all rows from two tables. The
two tables must be union compatible.
Relational Database OperatorsRelational Database Operators
INTERSECT produces a listing that contains onlythe rows that appear in both tables. The two tablesmust be union compatible.
8/9/2019 Ch.8b Supplementary Note-relational Database
8/11
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.
Relational Database OperatorsRelational Database Operators
PRODUCT roduces a list of all ossible airs of
rows from two tables.
8/9/2019 Ch.8b Supplementary Note-relational Database
9/11
Relational Database OperatorsRelational Database Operators
SELECT yields values for all attributes found in a table. Itields a horizontal subset of a table.
Relational Database OperatorsRelational Database Operators
PROJECT produces a list of all values for selectedattributes. It ields a vertical subset of a table.
8/9/2019 Ch.8b Supplementary Note-relational Database
10/11
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 allowin the use of
independent tables linked by common attributes.
Relational Database Operators
Natural JOIN links tables by selecting only the rowswith common values in their common attribute(s). Itis the result of a three-stage process:
A PRODUCT of the tables is created. (Figure2.12)
A SELECT is performed on the output of the firststep to yield only the rows for which the common
. .
A PROJECT is performed to yield a single copy,
duplicate column. (Figure 2.14)
8/9/2019 Ch.8b Supplementary Note-relational Database
11/11
Natural Join, Step 1: PRODUCT
Figure 2.13 Natural Join, Step 2: SELECT
Figure 2.14 Natural Join, Step 3: PROJECT