Richard, et al, Pls forgive the nuisance question here and my confusion. I had a question after my last lesson (Expert 9). I was asking about linking primary and foreign keys. To lighten his burden, I'm posting my question here.
I understand 1) Primary Key must be an Autonumber. 2) Foreign Key must also be a number (long integer) usually with the same name to form a relationship. For example, as Richard says, "If you're doing customers and orders, the CustomerID is the primary key in the customer table." NO ISSUES THERE. I get that part. It's potentially the second half of the equation where I have questions, if applicable. Here's where I'm unsure. (I even went back and listened to Expert 2.2. again, where he introduced explicit/global relationships (of the one-to-many variety), to try to clarify things in my own head.) My question: Must you ALSO enter the OrderID in CustomerT (i.e., the opposite direction, as a foreign key)? In other words, do BOTH TABLES require foreign keys AND primary keys from each corresponding table? If so, this would mean CustomerT would have BOTH CustomerID (primary key) and OrderID (foreign key), while OrderT would have OrderID (primary key) and CustomerID (foreign key). Based on my review of your simple tables in Expert 2.2 today, it appears not. Please confirm. v/r
Kevin Robertson
@Reply 4 years ago
You have basically answered your own question. You do not need the OrderID in the Customer Table.
At this stage in your Access learning, just think of it this way... both tables get their own Primary Key. The MANY side of a one-to-many relationship gets the other table's Primary Key as its Foreign Key. One customer - Many orders.
Kent JamisonOP
@Reply 4 years ago
Richard,
Thank you for the clarification. That is very helpful.
Sorry, only students may add comments.
Click here for more
information on how you can set up an account.
If you are a Visitor, go ahead and post your reply as a
new comment, and we'll move it here for you
once it's approved. Be sure to use the same name and email address.
This thread is now CLOSED. If you wish to comment, start a NEW discussion in
Access Expert 2.