Chapter 3
Chapter 3
INTERNATIONAL EDITION
Chapter 3 and 4
The Relational Database Model
1
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
Database Systems: Design, Implementation, & Management, International Edition, Rob, Coronel & Crockett 2
In this chapter, you will learn:
DATABASE SYSTEMS: Design Implementation and Management (Rob,
Coronel & Crockett 9781844807321)
2
B. The different types of keys and what they are used for
C. How to set rules to ensure the integrity of the data
D. About the data dictionary, and the system catalog
E. The different types of relationships within a relational database
F. How data redundancy is handled in the relational database
G. Why indexing is important
H. Codd’s 12 relational database rules
3
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
4
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
2 dimension structure ?
Database Systems: Design, Implementation, & Management, International Edition, Rob, Coronel & Crockett 7
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
2 dimension structure ?
Database Systems: Design, Implementation, & Management, International Edition, Rob, Coronel & Crockett 8
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
Database Systems: Design, Implementation, & Management, International Edition, Rob, Coronel & Crockett 9
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
Database Systems: Design, Implementation, & Management, International Edition, Rob, Coronel & Crockett 10
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
Database Systems: Design, Implementation, & Management, International Edition, Rob, Coronel & Crockett 11
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
Database Systems: Design, Implementation, & Management, International Edition, Rob, Coronel & Crockett 12
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
Database Systems: Design, Implementation, & Management, International Edition, Rob, Coronel & Crockett 13
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
Database Systems: Design, Implementation, & Management, International Edition, Rob, Coronel & Crockett 14
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
Database Systems: Design, Implementation, & Management, International Edition, Rob, Coronel & Crockett 15
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
Database Systems: Design, Implementation, & Management, International Edition, Rob, Coronel & Crockett 16
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
Database Systems: Design, Implementation, & Management, International Edition, Rob, Coronel & Crockett 17
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
Database Systems: Design, Implementation, & Management, International Edition, Rob, Coronel & Crockett 18
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Relational schema
Coronel & Crockett 9781844807321)
Student
19
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
20
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
Database Systems: Design, Implementation, & Management, International Edition, Rob, Coronel & Crockett 21
DATABASE
NorthwindSYSTEMS: Design Implementation
Traders databaseand Management
has (Rob,
a CATEGORIES table. 2
Coronel & Crockett 9781844807321)
How many cardinalities?
How many degrees of relation?
Database Systems: Design, Implementation, & Management, International Edition, Rob, Coronel & Crockett 22
DATABASE
NorthwindSYSTEMS: Design Implementation
Traders databaseand Management
has (Rob,
a CATEGORIES table. 2
Coronel & Crockett 9781844807321)
How many cardinalities?
How many degrees of relation?
Database Systems: Design, Implementation, & Management, International Edition, Rob, Coronel & Crockett 23
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
24
DATABASE
But theSYSTEMS: Design Implementation
PRODUCTS table and Management (Rob, 2
Coronel & Crockett 9781844807321)
has 95 products and
10 columns or attributes
25
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
Database Systems: Design, Implementation, & Management, International Edition, Rob, Coronel & Crockett 26
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
B. Keys
• Keys consist of one or more attributes that determine other
attributes
• Candidate key is an attribute that determines all the other
attributes in the relation. Choose primary key from these
• A candidate key is a column, or set of columns, in a table that
can uniquely identify any database record without referring to
any other data. Each table may have one or more candidate
keys, but one candidate key is unique, and it is called the
primary key. This is usually the best among the candidate keys
to use for identification.
27
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
Keys
B. Keys - Example
Foreign key
232 and 235
Occur twice
In PRODUCT
table
Primary key in VENDOR table 29
Database Systems: Design, Implementation, & Management, International Edition, Rob, Coronel & Crockett
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
B. Keys - Composite
31
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
32
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
B. Keys - Redundancy
• Controlled redundancy
– Tables within the database share primary/foreign keys that
enable the tables to be linked together
– Multiple occurrences of values in a table are not redundant
when they are required to make the relationship work, for
example the foreign key
– Redundancy exists only when there is duplication of
attribute values
– Having a foreign key means that you do not duplicate the
attributes in the table to which the foreign key links this
table. Therefore, it controls redundancy
33
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
B. Keys - Example
Foreign key
232 and 235
Occur twice
In PRODUCT
table
Primary key in VENDOR table 34
Database Systems: Design, Implementation, & Management, International Edition, Rob, Coronel & Crockett
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
Database Systems: Design, Implementation, & Management, International Edition, Rob, Coronel & Crockett 35
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
C. Integrity
• Two types
1. Entity integrity
2. Referential integrity
1. Entity integrity
– Ensures that each row is uniquely identified by the primary
key.
– It means that a proper search for an existing row will
always be successful.
– The failure to find a match on a row search will always
mean that the row for which the search is conducted does
not exist in that table.
36
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
C1. Entity Integrity question
Coronel & Crockett 9781844807321)
37
DATABASE SYSTEMS: Design Implementation and Management (Rob,
C2. Referential Integrity
Coronel & Crockett 9781844807321)
2
38
C2. Referential Integrity
DATABASE SYSTEMS: Design Implementation and Management (Rob,
Coronel & Crockett 9781844807321)
2
null
Database Systems: Design, Implementation, & Management, International Edition, Rob, Coronel & Crockett 39
C2. Referential Integrity
DATABASE SYSTEMS: Design Implementation and Management (Rob,
Coronel & Crockett 9781844807321)
2
question
• Based on the database shown in
Figure 2, do the tables exhibit
referential integrity? Answer yes
or no and explain your answers.
Write NA (Not Applicable) if the
table does not have a foreign key.
40
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
• Data dictionary
– Provides detailed accounting of all tables found within
the database
– Contains (at least) all the attribute names and
characteristics for each table in the system
– Hence, it contains metadata—data about data
41
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
Database Systems: Design, Implementation, & Management, International Edition, Rob, Coronel & Crockett 42
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
43
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
G. Indexes
• Arrangement used to logically access rows in a table like
finding a book in the library or a topic in a book
Database Systems: Design, Implementation, & Management, International Edition, Rob, Coronel & Crockett 44
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
Index
Database Systems: Design, Implementation, & Management, International Edition, Rob, Coronel & Crockett 45
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
46
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
47
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
Database Systems: Design, Implementation, & Management, International Edition, Rob, Coronel & Crockett 48
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
Database Systems: Design, Implementation, & Management, International Edition, Rob, Coronel & Crockett 49
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
50
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
51
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
52
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
53
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
Database Systems: Design, Implementation, & Management, International Edition, Rob, Coronel & Crockett 54
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
Dr. Codd's 12 Relational Database Rules
1) Information – All data must be stored in tables
2) Guaranteed Access – Access every value using Table + Column + Key
3) Systematic treatment of nulls – Nulls must be represented and treated in a
systematic way, independent of data type.
4) Dynamic on-line catalogue based on the relational model – The metadata
must be stored and managed as ordinary data, that is, in tables within the database.
Such data must be available to authorized users, using the standard database
relational language.
5) Comprehensive data sublanguage – The relational database may support many
languages. However it must support one well-defined declarative language with
support for data definition, view definition, data manipulation (interactive and by
program), integrity constraints, authorization and transaction management (begin,
commit and rollback)
6) View updating – Any view that is theoretically updatable must be updatable
through the system 55
Dr. Codd's 12 Relational Database Rules2
DATABASE SYSTEMS: Design Implementation and Management (Rob,
Coronel & Crockett 9781844807321)
7) High-level insert, update and delete – The database must support set-level
inserts, updates and deletes
8) Physical data independence – Application programs and ad hoc facilities are
logically unaffected when physical access methods and storage structures are
changed
9) Logical data independence – Application programs and ad hoc facilities are
logically unaffected when changes are made to the table structures that preserve
the original table values (changing order of column or inserting columns)
10) Integrity independence – All relational integrity constraints must be definable
in the relational language and stored in the system catalog, not at the application
level
11) Distribution independence – The end users and application programs are
unaware and unaffected by the data location (distributed vs local databases)
12) Non-subversion – If the system supports low-level access to the data, there
must not be a way to bypass the integrity rules of the database
Rule Zero – All preceding rules are based on the notion that in order for a
database to be considered relational, it must use its relational facilities exclusively
to Database
manage the Design,
Systems: database.
Implementation, & Management, International Edition, Rob, Coronel & Crockett 56
DATABASE SYSTEMS: Design Implementation and Management (Rob, 2
Coronel & Crockett 9781844807321)
Database Systems: Design, Implementation, & Management, International Edition, Rob, Coronel & Crockett 57