KT24603 Mod03
KT24603 Mod03
Design,
Implementation, and
Management, 14e
Module 3: The Relational Database
Model
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 1
Chapter Objectives (1 of 2)
2. Identify the relational model’s basic components and explain the structure, contents, and characteristics
of a relational table
4. Explain the purpose and components of the data dictionary and system catalog
5. Identify appropriate entities and then the relationships among the entities in the relational database
model
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 2
Chapter Objectives (2 of 2)
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 3
A Logical View of Data
• The relational data model allows the designer to focus on the logical representation of the data and
its relationships, rather than on the physical storage details
• The logical view is facilitated by the creation of data relationships based on a logical construct called
a relation
− It stores data in a concept of tables
• Simplest way to understand this is you are grouping the data in forms of tables which are related to
each other
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 4
Tables
• I repeat ! Simplest way to understand this is you are grouping the data in forms of tables which are
related to each other
ID Name Program
B
A
D
C
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 5
Tables and Their Characteristics (1 of 2)
• A table is perceived as a two-dimensional structure composed of rows and columns
• The domain is the set of allowable values for an attribute (e.g. program from the previous slide are
attributes that can have limited / allowable values)
• The primary key (PK) is an attribute or combination of attributes that uniquely identifies any given row
(i.e. the most unique one)
• The characteristics of a relational table are summarized in Table 3.1 on the following slide
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 6
Tables and Their Characteristics (2 of 2)
Table 3.1 Characteristics of a Relational Table
1 A table is perceived as a two-dimensional structure composed of rows and columns
2 Each table row (tuple) represents a single entity occurrence within the entity set
3 Each table column represents an attribute, and each column has a distinct name
4 Each intersection of a row and column represents a single data value
5 All values in a column must conform to the same data format
6 Each column has a specific range of values known as the attribute domain
7 The order of the rows and columns is immaterial to the DBMS
8 Each table must have an attribute or combination of attributes that uniquely identifies each row
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 7
Objective of using Relational Databases
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 8
Keys
• A key consists of one or more attributes that determine other attributes
− In short, if I say ID you can identify who am I talking about, what’s their name etc
− So, ID is a key that can determine name, program, etc
− Another example, you go to McD, order some burgers, the receipt will show your Order ID. Whenever
the buzzer buzz your number, you know your burgers are ready
− So, again, Order ID is a key. We can know what you order based on that order number.
• Keys are important because they are used to ensure that each row in a table is uniquely identifiable
− They are also used to establish relationships among tables and to ensure the integrity of the data
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 9
Dependencies
• The role of a key is based on the concept of determination, which is the state in which knowing the
value of one attribute helps to determine the value of another
• Functional dependence means that the value of one or more attributes determines the value of one or
more other attributes (via the symbol ‘->’)
• The attribute whose value determines another is called the determinant or the key
− Eg: studID -> studName, studProgram,
• The attribute whose value is determined by the other is called the dependent
− Eg: studID -> studName, studProgram
• Full functional dependence is used to refer to functional dependencies in which the entire collection of
attributes in the determinant is necessary for the relationship
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 10
Dependencies (cont.)
• A functional dependency is a particular relationship between two attributes.
• That is, for any relation R, attribute B is functionally dependent on attribute A if, for every valid instance
of A, that value of A uniquely determines the value of B.
A B
Dependent
Determinant
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 11
Example
• Remember: a functional dependency is a particular relationship between two attributes.
• Where A B
• icNo name
• And you can say that these values are unique enough to identify the whole relation
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 12
So, Keys
• Keys consist of one or more attributes that determine other attributes
− Ensure that each row in a table is uniquely identifiable
• Where A B
• Primary key (PK): attribute or combination of attributes that uniquely identifies a row
Name ID CGPA
Ali BI12 3.5
PK?
Foo BI13 3.52
Prem BI14 3.45
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 13
Types of Keys (1 of 3)
• Several different types of keys are used in the relational model
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 14
Types of Keys (1 of 3)
• A superkey is an attribute, or combination of attributes, that uniquely identifies each row in a table.
• A candidate key is a minimal superkey; that is, a key that does not contain a subset of attributes that is
itself a superkey
• Entity integrity is the condition in which each row in the table has its own known, unique identity
• A null is the absence of any data value, and it is never allowed in any part of a primary key
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 15
Types of Keys (2 of 3)
• A null could represent any of the following:
− An unknown attribute value
− A known, but missing, attribute value
− A “not applicable” condition
• A foreign key (FK) is a primary key of one table that has been placed in another table
• Referential integrity is a condition by which a dependent table’s foreign key entry must have either a
null entry or a matching entry in the primary key of the related table
• A secondary key is a key that is used strictly for data retrieval purposes and does not require a functional
dependency
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 16
Types of Keys (3 of 3)
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 17
Example
Sid Name Program Semest Gend Age Desc Result
me er er
Superkeys an attribute, or set of (Sid)
001 Jones BIT 4 M 20 attributes, that uniquely (Name)
identifies a tuple within (Sid, Name)
002 Parks BIT 4 M 21 a relation.
003 Baker BCP 3 M 19 Candidate unique and irreducible (Sid)
keys (Name)
004 Rusell BCP 3 M 20
Primary key a candidate key that is (Sid)
005 Rye DSE 3 M 18 selected to identify
tuples uniquely within
006 Susan BIT 4 F 20 the relation.
007 Diana DSE 3 F 19
008 Juliet DCS 3 F 17
009 Rafael DCS 3 M 19
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 18
Knowledge Check Activity 3-1
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 19
Knowledge Check Activity 3-1: Answer
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 20
Integrity Rules (1 of 2)
Table 3.4 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 known, unique identity, and foreign key values can properly reference primary key values.
Example No invoice can have a duplicate number, nor can it be null; in short, all invoices are uniquely identified by their invoice number.
Requirement A foreign key may have either a null entry, as long as it’s not part of its table’s primary key, or an entry that matches the primary key value in a table to
which it is related.
Every non-null foreign key value must reference an existing primary key value.
Purpose The purpose is to ensure that every reference by a foreign key is a valid reference to the related primary key. It is possible for an attribute not to have a
corresponding value, but it will be impossible to have an invalid entry; the enforcement of the referential integrity rule makes it impossible to delete a
row in one table whose primary key has mandatory matching foreign key values in another table.
Example A customer might not yet have an assigned sales representative (number), but it will be impossible to have an invalid sales representative (number).
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 21
Integrity Rules (2 of 2)
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 22
Relational Algebra
• Relational algebra is a set of mathematical principles that form the basis for manipulating relational table
contents
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 23
Formal Definitions and Terminology
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 25
Relational Set Operators
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 26
Relational Set Operators (2 of 7)
• Figure 3.6 UNION
• UNION is an operator used to merge two tables into a new table, dropping duplicate rows
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 27
Relational Set Operators
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 28
Relational Set Operators (3 of 7)
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 29
Relational Set Operators
• Figure 3.9 PRODUCT
• PRODUCT is an operator used to yield all possible pairs of rows from two tables
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 30
Relational Set Operators (4 of 7)
• Figure 3.10 Two Tables that Will be Used in JOIN
Illustrations
• JOIN allows information to be intelligently
combined from two or more tables
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 31
Relational Set Operators (5 of 7)
• Figure 3.12 Natural JOIN, Step 2: SELECT
• A SELECT is performed on the output of
Step 1 to yield only the rows for which the
AGENT_CODE values are equal
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 32
Relational Set Operators (7 of 7)
• Figure 3.16 DIVIDE
• The DIVIDE operator
− Uses one double-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
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 33
Divide
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 34
Time to take 10
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 35
The Data Dictionary and the
System Catalog
• The data dictionary provides a detailed description of all tables in the database created by the user and
designer
− It is sometimes described as “the database designer’s database” because it records the design
decisions about tables and their structures
• The system catalog is a detailed system data dictionary that describes all objects within the database
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 36
Relationships within the Relational Database (1 of
6)
• The one-to-many (1:M) relationship is the norm for relational databases
• In the one-to-one (1:1) relationship, one entity can be related to only one other entity and vice versa
• The many-to-many (M:N) relationship can be implemented by creating a new entity in 1:M relationships
with the original entities
− A composite entity (i.e., bridge or associative or linkup entity) helps avoid problems inherent to
M:N relationships
It includes the primary keys of tables to be linked
i.e. the linkup tables
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 37
• 1:1
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 38
STUDENT ID NAME
BI123 Muthu
BI222 Ali
M:N BI111 Chong
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 39
1:M
1:M M:1
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 40
See the data
• Figure 3.27 The
Expanded ER Model
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 41
Data Redundancy Revisited (1 of 2)
• The relational database facilitates control of data redundancies through use of foreign keys
− Recall that foreign keys are common attributes that are shared by tables
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 42
Data Redundancy Revisited (2 of 2)
• Figure 3.29 A Small Invoicing System
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 43
Indexes (1 of 2)
• In short, it’s like a pointer – points to whatever data that you are looking for
• If don’t have this – then have to search (view) all part of the database (time matters)
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 44
Indexes (2 of 2)
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 45
Cobb’s Relational Database Rules (1 of 2)
Table 13.8 Dr. Codd’s 12 Relational Database Rules
1 Information All information in a relational database must be logically represented as column values in rows within tables.
2 Guaranteed access Every value in a table is guaranteed to be accessible through a combination of table name, primary key value,
and column name.
3 Systematic treatment of nulls Nulls must be represented and treated in a systematic way, independent of data type.
4 Dynamic online catalog based The metadata must be stored and managed as ordinary data—that is, in tables within the database; such data
on the relational model must be available to authorized users using the standard database relational language.
5 Comprehensive data The relational database may support many languages; however, it must
sublanguage support one well-defined, declarative language as well as 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.
7 High-level insert, update, and delete The database must support set-level inserts, updates, and deletes.
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 46
Cobb’s Relational Database Rules (2 of 2)
Table 13.8 Dr. Codd’s 12 Relational Database Rules
8 Physical data independence Application programs and ad hoc facilities are logically unaffected when physical access methods or 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 columns 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 of and unaffected by the data location (distributed vs.
local databases).
12 Nonsubversion If the system supports low-level access to the data, users must not be allowed to bypass the integrity rules of
the database.
13 Rule zero All preceding rules are based on the notion that to be considered relational, a database must use its relational
facilities exclusively for management.
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 47
Knowledge Check Activity 3-3
• Explain why the data dictionary is sometimes called "the database designer's
database."
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 48
Knowledge Check Activity 3-3: Answer
• Explain why the data dictionary is sometimes called "the database designer's
database."
• Answer: Just as the database stores data that is of interest to the users regarding the
objects in their environment that are important to them, the data dictionary stores data
that is of interest to the database designer about the important decisions that were
made in regard to the database structure. The data dictionary contains the number of
tables that were created, the names of all of those tables, the attributes in each table, the
relationships between the tables, the data type of each attribute, the enforced domains of
the attributes, etc.
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 49
Summary (1 of 2)
Now that the lesson has ended, you should be able to:
2. Identify the relational model’s basic components and explain the structure, contents, and characteristics
of a relational table
4. Explain the purpose and components of the data dictionary and system catalog
5. Identify appropriate entities and then the relationships among the entities in the relational database
model
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 50
Summary (2 of 2)
Now that the lesson has ended, you should be able to (continued):
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 51
Takeaways
Coronel, Carlos and Morris, Steven, Database Systems: Design, Implementation, and Management, 14 Edition. © 2023 Cengage. All Rights Reserved. May
not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 52