| INTRODUCTION TO RELATIONAL DATABASES |
|
|
|
|
|
| The
Problem with Flat File Databases |
|
|
|
|
EMPLOYEE INFO TABLE |
|
|
|
|
FIRST NAME |
LAST NAME |
|
|
|
Joe |
Hanley |
HR |
|
|
Fred |
Hanrahan |
Sales |
|
|
Sam |
Hill |
Production |
|
Sales |
|
|
Sidney |
Hopper |
Mktg |
|
|
Bill |
Kaiser |
Sales |
|
|
Sherry |
Lane |
Sales |
|
HR |
|
|
Janet |
Lavin |
HR |
|
|
Sergio |
Lopez |
Mktg |
|
|
Gillian |
Roberts |
HR |
|
Mktg |
|
|
Clarence |
Tomkins |
Mktg |
|
|
Fritz |
Webb |
Mktg |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| The
Solution |
|
|
|
|
Wouldn't it be nice to
just store these values a single time. |
|
|
- in a separate table |
|
|
Then you could call them
up when you needed them. |
|
|
|
|
|
|
DEPARTMENT CODES TABLE |
|
|
|
|
|
DEPARTMENT |
|
|
|
Sales |
|
|
|
HR |
|
|
|
Mktg |
|
|
|
Production |
|
|
|
|
|
| Relations
Between Tables |
|
|
|
|
EMPLOYEE INFO TABLE |
|
DEPARTMENT CODES TABLE |
|
|
|
|
|
DEPARTMENT |
|
|
LAST NAME |
|
|
|
|
DEPT |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EMPLOYEE INFO TABLE |
|
DEPARTMENT CODES TABLE |
|
FIRST NAME |
|
|
|
DEPARTMENT |
|
|
LAST NAME |
|
|
|
|
DEPT |
|
|
|
|
|
|
|
|
|
| The
One-to-Many Relation |
|
|
|
|
One of the classic types
of relations is the "One-Many" relationship. |
|
|
- store a value once, re-use it many times |
|
|
- there are other (less widely used) types
of relations |
|
|
|
|
EMPLOYEE INFO TABLE |
|
DEPARTMENT CODES TABLE |
|
FIRST NAME |
|
|
|
DEPARTMENT |
|
|
LAST NAME |
|
|
|
|
DEPT |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|