Chapter 4 - Intro - InClass Demo
Chapter 4 - Intro - InClass Demo
Chapter 2
Logical Data Modelin
Representing the database in
Immediately create tables
Data Modeling
ting the database in terms of the databse technology used to implement the
ely create tables
Chapter 4
d to implement the DB.
Components of relational mo
Ò Data structure
É Tables (relations), rows, column
Ò Data manipulation
É Powerful SQL operations for retr
Ò Data integrity
É Mechanisms for implementing b
ional model
s, columns
Dept_ID Dept_Name
1 MIS
2 FIN
3 SCM
PK
Employee_ID
1
2
3
4
5
6
7
How to represent them?
PK Primary keys are unique identifiers of the relation. Examples include
How to represent?
FK Foreign keys are identifiers that enable a dependent relation (on the
How to represent?
Relationships: How to represent?
Two Ways
Graphical
EMPLOYEE
Employee_ID Employee_Name Employee_Age
DEPARTMENT
Dept_ID Dept_Name
SKILLS
Skill_ID Skill_Name
mensional table of data.
and columns (attribute or field).
relation:
EMPLOYEE
Skill_ID Skill_Name
1 Data Entry
2 Dance
3 Drama
4 Programming
5 Data analysis
6 Accounting
dentifiers of the relation. Examples include employee numbers, social security numbers, etc. This guarantees that all rows are u
s that enable a dependent relation (on the many side of a relationship) to refer to its parent relation (on the one side of the rel
Employee_Latitude Employee_Longitude
100 35
120 89
110 56
100 36
120 90
110 57 even though they are the same they have diff primary key
110 57
Employee_ID
1
1
1
2
3
4
5
6
Dept_ID
bad table
SSIGNMENT
Skill_ID
1
2
3
4
5
6
4
5
nal database) is NOT the same as the word relationship (in E-R model).
(in E-R model).
INTEGRITY CONSTRAINTS
Rules limiting acceptable values or actions, whose purpose is to facilitate mai
ÒDomain Constraints
ÉDomain: Allowable values for an attribute
ÒEntity Integrity
ÉNo primary key attribute may be null. All primary k
What about these two tables? Is entity integriy enforced?
What is NULL?
A value that must be assigned to an attribute when no other value applies or when the applicable valu
Examples?
ÒReferential Integrity
ÉRules that maintain consistency between the rows
to facilitate maintaining the accuracy and integrity of the data in DB and to enforce b
CustomerID
L ASSIGNMENT
EMPLOYEE
PK
Employee ID Employee Na Employee Age
1 Mary 32
2 Sue 21
3 John 30
4 Smith 45
5 Smith 45
6 Joey 25
DEPARTMENT
FK PK
Dept ID Dept ID Dept Name
1 1 MIS
1 2 FIN
2 3 SCM
2 4 LEAD
3
3
How to depict referential Integrity?
In the relation diagrams of this chapter, arrows between foreign and pr
Refere
integrity co
are draw
arrows
dependent
tabl
Referential
integrity constraints
are drawn via
arrows from
dependent to parent
table
Revisiting referential integrity definition:foreign key must have a matching primary key o
Restrict
EMPLOYEE
Cascade
EMPLOYEE
Set-to-Null
EMPLOYEE
DEPARTMENT
DEPARTMENT
DEPARTMENT