Information Systems Program
Module 3
Relational Data Model and
CREATE TABLE Statement
Lesson 2: Integrity Rules
Lesson Objectives
• Identify 1-M relationships and associated primary
keys (PKs) and foreign keys (FKs)
• Find errors in rows with either orphan FKs or
missing FKs
• Identify situations for FK requirements
– FK is necessary
– FK can have the null value
Information Systems Program
Definitions
• Absence of a value (missing value)
Null value • Actual value unknown or not applicable for a row
Primary • Column or combination of columns with unique
values in each row
key (PK) • No extraneous columns (minimal)
Foreign • Column or combination of columns
• Related to a primary key in a related table
• Same data type and often same name as related
key (FK) PK
Information Systems Program
Integrity Rules
• Primary key for each table
• No missing (null) values for primary
Entity keys
• Ensures traceable entities
Integrity
• Two kinds of values for a foreign key in
a row
Referential • Match a primary key value of a related
table (usual)
Integrity • Null value (unusual)
• Ensures valid references among tables
Information Systems Program
Integrity Rule Violations
Student Offering
StdNo StdLastName OfferNo CourseNo
123-45-6789 WELLS 1234 IS320
124-56-7890 KENDALL 4321 IS320
234-56-7890 NORBERT
-- JONES
Enrollment
StdNo OfferNo
123-45-6789 1234
234-56-7890 1234
123-45-6789 4321
124-56-7890 4321
234-56-7890 6789
-- 4321
Information Systems Program
Oracle Relational Diagram
Information Systems Program
Summary
• Identify primary keys and foreign keys
• Visualize relationships
• Understanding existing databases is crucial to
query formulation
Information Systems Program