Patty:

When you go into the relationships window in Access 2000, you can add your tables 
(which I gather you've done) to the diagram and then specify which fields match up, 
whether to enforce referential integrity between them, and what join type they use.  
Basically once you relate a primary key to other fields, those fields are considered 
foreign keys to the primary.

So you only want one primary key called cabinID in the cabins table.  The cabinID 
fields in the other two tables, the photo tables, will be foreign keys, which you 
don't have to specify directly.  Basically they can even be foreign keys if you DON'T 
specify a relationship between them and the primary key, however as a best practice 
you want to have the database do as much work as possible so you don't have to 
manually enforce the relationships or cascade update and delete manually within your 
code.

I've responded more below under your questions:


> -----Original Message-----
> From: P@tty Ayers [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, April 05, 2001 7:59 PM
> To: CF-Talk
> Subject: Re: Could Not Delete From Specified Tables
> 
> 
> 
> Andy - Thanks for your response. (Still welcoming any help from others as
> well..)
> 
> > Do you mean you have a primary key called photoID in this table as a
> primary key?  cabinID in this table should be a foreign key, 
> related to the
> cabins table.
> 
> Okay, I just checked and no, actually I didn't make photoID in the table
> 'photos' a primary key. I *did* make 'otherphotoID' in 'otherphotos' a
> primary key.
> 
> Let me see if I am understanding you - should the two secondary 
> tables, each
> which have a 'cabinID' column, each have 'cabinID' as a foreigh key, and
> neither should have a primary key?

Both should have a primary key (again as a good database design practice, but not 
always necessary).  Name the keys whatever you want.  I suggest photoID and 
otherphotoID, as you have it now.  Both should also have cabinID as a foreign key, 
related to the primary key cabinID in the cabins table.

> 
> And (forgive my ignorance) how do I make a foreign key? I'm looking in
> Access's help files and a reference book, but haven't found it yet.

In the relationships window, you can specify which keys are related.  You can, for 
instance, click on the primary key in cabins (cabinID), hold down the mouse button and 
drag to the foreign key in photos (cabinID).  A box will pop up (I take it you 
might've done this already) where you can specify more options for how the fields are 
related, join types, and more.


Sorry if I've repeated myself -- it's late and time to sleep!


- Andy
 


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to