W3 Relational Data Model
W3 Relational Data Model
Data Model
Learning Objectives
2
Learning Objectives
3
A Logical View of Data
+ Relational database model enables logical
representation of the data and its relationships
+ Logical simplicity yields simple and effective
database design methodologies
+ Facilitated by the creation of data relationships
based on a logical construct called a relation
4
Characteristics of a Relational Table
5
Keys
+ Consist of one or more attributes that determine other
attributes
+ Used to:
Ensure that each row in a table is uniquely identifiable
Establish relationships among tables and to ensure the integrity of the data
+ Primary key (PK): Attribute or combination of attributes that
uniquely identifies any given row
6
Determination
7
Dependencies
+ Functional dependence: Value of one or more attributes
determines the value of one or more other attributes
Determinant: Attribute whose value determines another
Dependent: Attribute whose value is determined by the other attribute
+ Full functional dependence: Entire collection of attributes in
the determinant is necessary for the relationship
8
Types of Keys
9
Types of Keys
10
Relational Database Keys
11
An Example of a Simple Relational
Database
12
Integrity Rules
Entity Integrity Description
Requirement All primary key entries are unique,
and no part of a primary key may be
null
Purpose Each row will have a unique identity,
and foreign key values can properly
reference primary key values
13
Integrity Rules
Entity Integrity Description
Requirement A foreign key may have either a null
entry or a entry that matches a primary
key value in a table to which it is
related
Purpose It is possible for an attribute not to
have a corresponding value but it is
impossible to have an invalid entry
14
An Illustration of Integrity Rules
15
Ways to Handle Nulls
16
Relational Algebra
17
Relational Set Operators
Select (Restrict)
•Unary operator that yields a horizontal subset of a table
Project
•Unary operator that yields a vertical subset of a table
Union
•Combines all rows from two tables, excluding duplicate rows
•Union-compatible: Tables share the same number of columns,
and their corresponding columns share compatible domains
Intersect
•Yields only the rows that appear in both tables
•Tables must be union-compatible to yield valid results
18
Select
19
Project
20
Union
21
Intersect
22
Relational Set Operators
+ Difference
Yields all rows in one table that are not found in the other table
Tables must be union-compatible to yield valid results
+ Product
Yields all possible pairs of rows from two tables
23
Relational Set Operators
+ Join
Allows information to be intelligently combined from two or more tables
+ Divide
Uses one 2-column table as the dividend and one single-column table as
the divisor
Output is a single column that contains all values from the second column
of the dividend that are associated with every row in the divisor
24
Types of Joins
25
Types of Joins
26
Figure 3.8 - Difference
27
Product
28
Two Tables That Will Be Used in JOIN
Illustrations
29
Divide
30
Data Dictionary and the System
Catalog
+ Data dictionary: Description of all tables in the database
created by the user and designer
+ System catalog: System data dictionary that describes all
objects within the database
+ Homonyms and synonyms must be avoided to lessen
confusion
+ Homonym: Same name is used to label different attributes
+ Synonym: Different names are used to describe the same attribute
31
Relationships
+ 1:M relationship -within the Relational
Norm for relational databases
Database
+ 1:1 relationship - One entity can be related to only
one other entity and vice versa
+ Many-to-many (M:N) relationship - Implemented
by creating a new entity in 1:M relationships with
the original entities
Composite entity (Bridge or associative entity): Helps avoid
problems inherent to M:N relationships, includes the primary keys
of tables to be linked
32
The 1:1 Relationship between PROFESSOR and
DEPARTMENT
33
Changing the M:N Relationship to Two
1:M Relationships
34
The Expanded ER Model
35
Data Redundancy
36
The Relational Diagram for the Invoicing
System
37
Index
38