AboutScottgem Expertise I can answer almost all types of questions relating to Microsoft Access usage and application design. My strengths are database and interface design.
Experience I've been designing databases for over 15 years working with dBase, FoxPro, Approach and Access.
Organizations Author of Microsoft Office Access 2007 VBA Techncial Editor for Special Edition Using Microsoft Access 2007 and Access 2007 Forms, Reports & Queries From Que Publishing
Question Hello. I'm a new user and I am really struggling with primary keys and relationships. Can you give me a definition of why primary keys are used and how relationships and primary keys are important when setting up a database. I just don't get the concept of primary keys vs. a foreign keys. and their differences. Please help!
Answer A primary key is a unique identifier for a record. A foreign key is a field in a related record that points back to the parent record. This is best illustrated with the classic Order Entry scenario.
A customer orders some items. You do not want the Order record to repeat multiple pieces of Information about a customer. But there has to be a way to identify which customer is making the order and to link back to all their information. So the customer table has a PK field which uniquely identifies the customer. The order table has a foreign key that stores the value of the CustomerID so you can join the two tables to get the customer data (i.e if the PK for the Customer = 123, then the FK in the Order table would show 123 for all that customer's orders)
If you don't have a primary key, how are you going to know which customer placed the order? the PK has to be guaranteed to be uinique to a customer. That's why its recommended that you use Autnumbers for your PKs in most cases, they are guaranteed to be unique.
Hope this helps,
Scott<>
Microsoft Access MVP 2007
Author: Microsoft Office Access 2007 VBA