Introduction to the relational model – some theory A relation r on

advertisement
Introduction to the relational model – some theory
A relation r on domains D1, D 2, …, Dk is any subset of
D1XD2X … XDk
For example, r = { <123-45-6789, Deepthi, $95K>, <987-654321, Brian, $88K>}
More often presented as:
idNo
123-45-6789
987-65-4321
name
Deepthi
Brian
salary
$55K
$88K
Employees
Question – for each of the relation instances (aka “tables”)
below, is it very similar or equal to the one above?
the first one:
idNo
987-65-4321
123-45-6789
name
Brian
Deepthi
the second one (trick question!):
name
salary
Deepthi
$55K
Brian
$88K
salary
$88K
$55K
idNo
123-45-6789
987-65-4321
Figure 3.2
Fname
Minit
ER
schema diagram for the company database.
Lname
Number
Address
Name
Sex
1
N
WORKS_FOR
Name
Locations
Salary
Ssn
___
DEPARTMENT
NumberOfEmployees
StartDate
EMPLOYEE
Bdate
1
1
1
MANAGES
CONTROLS
N
Hours
supervisor
supervisee
N
WORKS_ON
1
SUPERVISION
PROJECT
1
N
Name
Location
Number
______
DEPENDENTS_OF
N
DEPENDENT
Name
Sex
BirthDate
Relationship
© Addison Wesley Longman, Inc. 2000, Elmasri/Navathe, Fundamentals of Database Systems, Third Edition
Figure 7.6 One possible relational database state
corresponding to the COMPANY schema.
EMPLOYEE
FNAME
MINIT
John
Franklin
Alicia
Jennifer
Ramesh
Joyce
Ahmad
James
LNAME
SSN
Smith
Wong
Zelaya
Wallace
Narayan
English
Jabbar
Borg
123456789
333445555
999887777
987654321
666884444
453453453
987987987
888665555
BDATE
ADDRESS
1965-01-09
1955-12-08
1968-01-19
1941-06-20
1962-09-15
1972-07-31
1969-03-29
1937-11-10
731 Fondren, Houston, TX
638 Voss, Houston, TX
3321 Castle, Spring, TX
291 Berry, Bellaire, TX
975 Fire Oak, Humble, TX
5631 Rice, Houston, TX
980 Dallas, Houston, TX
450 Stone, Houston, TX
SEX
SALARY
SUPERSSN
DNO
M
M
F
F
M
F
M
M
30000
40000
25000
43000
38000
25000
25000
55000
333445555
888665555
987654321
888665555
333445555
333445555
987654321
null
5
DEPT_LOCATIONS
DNUMBER
5
4
4
5
5
4
1
DLOCATION
Houston
Stafford
DEPARTMENT
WORKS_ON
DEPENDENT
DNAME
DNUMBER
MGRSSN
MGRSTARTDATE
Research
Administration
Headquarters
5
4
1
333445555
987654321
888665555
1988-05-22
1995-01-01
1981-06-19
ESSN
PNO
HOURS
123456789
123456789
666884444
453453453
453453453
333445555
333445555
333445555
333445555
999887777
999887777
987987987
987987987
1
2
3
1
2
2
3
10
20
30
10
10
30
32.5
7.5
987654321
987654321
30
20
20.0
888665555
20
Bellaire
Sugarland
40.0
20.0
20.0
10.0
PROJECT
PNAME
PNUMBER
ProductX
10.0
10.0
10.0
ProductY
ProductZ
Computerization
Reorganization
30.0
10.0
35.0
5.0
Newbenefits
PLOCATION
DNUM
Bellaire
Sugarland
Houston
5
5
5
10
Stafford
4
20
30
Houston
Stafford
1
4
1
2
3
15.0
null
ESSN
DEPENDENT_NAME
SEX
333445555
333445555
333445555
Alice
Theodore
Joy
F
M
F
1986-04-05
1983-10-25
1958-05-03
BDATE
RELATIONSHIP
DAUGHTER
SON
SPOUSE
987654321
123456789
123456789
Abner
Michael
Alice
M
M
F
1942-02-28
1988-01-04
1988-12-30
SPOUSE
SON
DAUGHTER
123456789
Elizabeth
F
1967-05-05
SPOUSE
© Addison Wesley Longman, Inc. 2000, Elmasri/Navathe, Fundamentals of Database Systems, Third Edition
Figure 7.7 Referential integrity constraints displayed
on the COMPANY relational database schema diagram.
EMPLOYEE
FNAME
MINIT
LNAME
SSN
BDATE
ADDRESS
SEX
SALARY
SUPERSSN
DEPARTMENT
DNUMBER
DNAME
MGRSSN
MGRSTARTDATE
DEPT_LOCATIONS
DNUMBER
DLOCATION
PROJECT
PNAME
PNUMBER
PLOCATION
DNUM
WORKS__ON
ESSN
PNO
HOURS
DEPENDENT
ESSN
DEPENDENT_NAME
SEX
BDATE
RELATIONSHIP
© Addison Wesley Longman, Inc. 2000, Elmasri/Navathe, Fundamentals of Database Systems, Third Edition
DNO
Download