2006/10/05 Source:
-
Upload
verity-holmes -
Category
Documents
-
view
216 -
download
1
Transcript of 2006/10/05 Source:
Conceptual Design
Logical Design
Physical Design
Database Requirement
Conceptual Schema
Logical Schema
(the data model of a specific DBMS )
Miniworld
Internal Schema
DBMS-Independent
DBMS-Specific
Three-phases of database design
E/R model
Entity name: Employee
Name,Age,Salary
e1:(John, 55, 80k)
e2:(Fred, 40, 30k)
e3:(Judy, 25, 20k)
Entity Set
Logical data model
Network Database Model
Hierarchical Database Model
Relational Database Model
Object-oriented Database Model
Relational database model
(E. F. Codd 1970)
Ssn Name Bdate Sex Adddress Salary Workfor
S001 John 1957/10/01 M Taipei 25000 D001
S002 Mary 1967/02/05 F Taipei 20000 D002
S003 Jack 1977/05/05 M Taipei 30000 D002
S004 Jone 1970/07/02 F Hualien 35000 D001
Domain
Atomic value
Tuple
Relation
Attribute Relation schema
Primary key
Degree
E/R model Relational model
Database File system
Entity set Relation Table File
Entity Tuple Row Record
Attribute Attribute Column Field
E-R diagram for the company schema
Employee
Workfor
Department
N1
Manages
11
Project
Control
Works_on
Dependents
Dependents of
name
Fname Lname
sex
ssn
RelationshipName
M
N N
11
N
StartDate
NameLocations
Sex Birthday
Number
Hours
Number Name
Locations
Referential integrity
constraint
Fname Minit Lname Ssn Bdate Address Sex Salary Superssn Dno
Dnumber Dlocation
Essn Department_name Sex Bdate Relationship
Essn Pno Hours
Dname Dnumber Mgrssn Mgrstartdate
Pname Pnumber Plocation Dnum
Employee
Department
Dept_Location
Project
Works_on
Dependent
Logical schema
Multivalue entity
Relational constraints
Inherent model based constraints
Schema –based constraints
1. Domain constraints ex. Atomic value
2. Key constraints ex. superkey, primary key
3. Null value constraints
4. Entity integrity no primary key value can be null
5. Referential integrity (foreign key)
Application-based constraints
Data dependency constraints (chapter 10)
1st normal form, 2nd normal form, …
Super key
Candidate key
Primary key Alternate key Foreign key
Attribute sets
(sid), (ssn), (sid,ssn), (sid, ename)
(ssn, tel) (ssn, age), (ssn,name,postcode)(sid), (ssn)
(sid) (ssn)
• Unique
• Unique
• never change
• Non-identifying value
• Brevity and simplicity
Suppose R(a,b,c) and S(c,d) are two relations. Let
R.c be the foreign key and refer to S.c. Which of the
followings satisfies referential integrity ?
(A) R={(1,2,3) , (1,4,9) , (1,5,5)} , S={(3,7) , (5,8)}
(B) R={(1,2,3) , (1,4,9) , (1,5,6)} , S={(3,7) , (9,8)}
(C) R={(1,2,4) , (1,4,9) , (1,5,7)} , S={(4,7) , (7,8)}
(D) R={(1,2,4) , (1,4,6) , (1,5,6)} , S={(4,7) , (6,8)}
. R.C. that is, if an object or entity A is related to object B or entity B, then B must really exist
Referential integrity
Ssn Name Bdate Sex Adddress Salary Workfor
S001 John 1957/10/01 M Taipei 25000 D001
S002 Mary 1967/02/05 F Taipei 20000 D002
S003 Jack 1977/05/05 M Taipei 30000 D002
S004 Jone 1970/07/02 F Hualien 35000 D001
Pnumber Plocation Dnumber
P001 Bellaire D001
P002 Suqarland D002
P003 Houston D001
P004 Houston D003
Dnumber Name Location
D001 R&D_1 New Jercy
D002 Sale New York
D003 R&D_2 California
Name Ssn Bdate Relationship
Mary_f S002 1937 Father
Mary_m S002 1937 Mother
Jack_d S003 1987 Daughter
A possible snapshot of Company database
Ssn Pnumber Hours
D001 P001 32
D001 P003 75
D003 P001 40
Dependent
Employee
DepartmentWorks_on
Project
Normal form
Ssn Ename Projs
Pnumber Hours123456789 Smith John B 1 32
2 8
666884444 Narayan 3 40
453453453 English, Joyce A. 1 20
2 20
3334455555 Wong, Franklin T. 2 10
3 10
10 10
20 10
999887777 Zelaya,Alicia J. 30 30
10 10
987987987 Jabbar,Ahmad V. 10 35
30 5
987654321 Wallace,Jennefer S. 30 20
20 15
888665555 Borg, James E. 20 null
First normal form
Ssn Ename Projs
Pnumber Hours123456789 Smith John B 1 32
123456789 Smith John B 2 8
666884444 Narayan 3 40
453453453 English, Joyce A. 1 20
453453453 English, Joyce A. 2 20
3334455555 Wong, Franklin T. 2 10
3334455555 Wong, Franklin T. 3 10
3334455555 Wong, Franklin T. 10 10
3334455555 Wong, Franklin T. 20 10
999887777 Zelaya,Alicia J. 30 30
999887777 Zelaya,Alicia J. 10 10
987987987 Jabbar,Ahmad V. 10 35
987987987 Jabbar,Ahmad V. 30 5
987654321 Wallace,Jennefer S. 30 20
987654321 Wallace,Jennefer S. 20 15
888665555 Borg, James E. 20 null