Lesson 4 For Tuesday, January 05, 2010 Creating Relationships
Lesson 4 For Tuesday, January 05, 2010 Creating Relationships
PD PD
1/5/2010 Develop Business applications with Micr…
!
W
W
O
O
N
N
y
y
bu
bu
to
to
k
k
lic
lic
C
C
w
w
m
m
w w
w
w
o
o
.d o .c .d o .c
c u -tr a c k c u -tr a c k
Creating relationships
Note that there are several fields in both tables that refer to Links to other table. The reason for that is that
Relationships are very powerful in database design.
www.profsr.com/access/accless04.htm 1/5
F -X C h a n ge F -X C h a n ge
PD PD
1/5/2010 Develop Business applications with Micr…
!
W
W
O
O
N
N
y
y
bu
bu
If you have to keep a record of the customer's c redit card name, number and expiry date you will create 3 fields in the
to
to
k
k
table. Obviously, c ard number and date will be individual but, you may have 2,000 c ustomers with Visa. When you
lic
lic
C
C
w
w
m
m
w
enter the c ustomer's record you c ould just type "Visa" for the c ard name. But what if the person keying the data keys w
w
w
o
o
.d o .c .d o .c
c u -tr a c k c u -tr a c k
"Viza" instead, or " Visa", or "Vissa", or ...... If, later on you have to have a list of all c ustomers with a "Visa" card, all
those entered incorrectly won't show-up.
And what if Visa decided to change its name to VizaCard? You would have to go through the rec ords and c hange
2,000 customers.
The solution to those problems is: don't key the c ard name into the rec ord, selec t the name from a list, and the list
will c ome from another table.
In this c ase, we create a CreditCard table and it will contain only a list of credit c ards that we will ac cept.
The c ustomer record won't actually contain the c redit c ard name, it will contain a pointer to the CreditCard table. If
ever a card company changes its name, we only need to change the name in the CreditCard table and all customers
who point to that name will automatic ally be c hanged.
www.profsr.com/access/accless04.htm 2/5
F -X C h a n ge F -X C h a n ge
PD PD
1/5/2010 Develop Business applications with Micr…
!
W
W
O
O
N
N
y
y
bu
bu
to
to
k
k
lic
lic
C
C
w
w
m
m
w w
w
w
o
o
.d o .c .d o .c
c u -tr a c k c u -tr a c k
www.profsr.com/access/accless04.htm 3/5
F -X C h a n ge F -X C h a n ge
PD PD
1/5/2010 Develop Business applications with Micr…
!
W
W
O
O
N
N
y
y
bu
bu
to
to
k
k
lic
lic
C
C
w
w
m
m
w w
w
w
o
o
.d o .c .d o .c
c u -tr a c k c u -tr a c k
The fields: Category, Rating, Language, Format c an all be stored in other tables and linked to Movies.
The same princ iples will apply. If you add a new category, you add it only once to the Categories table. If a category
name changes, you change it onc e, in the Categories table.
The only differenc e in those tables is that we've given eac h item in the list a number: 1 = Action, 2 = Romance, etc .
The list will still work the same as the CreditCard table.
Here's what you will eventually get when all the tables and relationships are set-up. Don't worry about all the extra
tables, we'll get to those in the following lessons.
www.profsr.com/access/accless04.htm 4/5
F -X C h a n ge F -X C h a n ge
PD PD
1/5/2010 Develop Business applications with Micr…
!
W
W
O
O
N
N
y
y
bu
bu
to
to
k
k
lic
lic
C
C
w
w
m
m
w
Next week: Entering data into tables. See you then! w
w
w
o
o
.d o .c .d o .c
c u -tr a c k c u -tr a c k
www.profsr.com/access/accless04.htm 5/5