Topic 3 Relational Data Model Ict200
Topic 3 Relational Data Model Ict200
Relational model
Enables programmer to view data logically rather
than physically
Table
Resembles a file from conceptual point of view
Has advantages of structural and data
independence
Easier to understand than its hierarchical and
network database predecessors
Tables and Their Characteristics
4
Table:
two-dimensional structure composed of rows and
columns
2. Each table row (tuple) represents a single entity occurrence within the
entity set
Composite key
Composed of more than one attribute
Key attribute
Any attribute that is part of a key
Superkey
Any key that uniquely identifies each row. Example : stuNum,
stuNum+stuLname
Candidate key
A superkey without unnecessary attributes / minimal superkey
Primary key is a superkey as well as a candidate key
Example : stuNum+stuLname→ superkey but not
candidate key, because stuNum by itself is a candidate
key!
Keys
12
Secondary key
Key used strictly for data retrieval purposes
Nulls
No data entry
Not permitted in primary key
Should be avoided in other attributes
Can represent
◼ An unknown attribute value
◼ A known, but missing, attribute value
◼ A “not applicable” condition
Can create problems when functions such as COUNT,
AVERAGE, and SUM are used
Can create logical problems when relational tables are
linked
Keys
Keys
15
Controlled redundancy
Makes the relational database work
Relational Schema
A textual representation of the database tables
Example:
VENDOR (VEND_CODE, VEND_CONTACT, VEND_AREACODE, VEND_PHONE)
Relational Diagram
Shows link between tables
Entity integrity
Allprimary key unique and no part of a PK may
be null
Referential integrity
FK contains a value that refers to an existing valid
tuple (primary key) in another relation
Entity Integrity
Referential Integrity
Integrity Rules
Ways to Handle Nulls
22
Data dictionary
Provides detailed description of all tables found within the
user/designer-created database
System catalog
Contains metadata
26
Relationships within the Relational
Database
27
1:M relationship
Relational modeling ideal
Should be the norm in any relational database design
1:1 relationship
Should be rare in any relational database design
M:N relationships
Cannot be implemented as such in the relational model
M:N relationships can be changed into two 1:M relationships
The 1:M Relationship
28
Composite entity
40
Composite entity
ERD for Tiny College
41
Relational Diagram for Tiny College
42
Data Redundancy Revisited
43
Unique index
Index in which the index key can have only one pointer
value (row) associated with it
Each index is associated with only one table
Indexes
48
Summary
Tables are basic building blocks of a relational database
Keys are central to the use of relational tables
Keys define functional dependencies
Superkey
Candidate key
Primary key
Secondary key
Foreign key
Summary
49
1.Briefly explain the terms listed below and DRAW example for
each:
i. primary key
ii. Foreign key
iii. Composite key