Relationship/primary key "rules"

EjS

New Member
Joined
Jun 30, 2002
Messages
48
Hi-I am looking for a quick "rules" overview on relationships/primary keys. I tend to want to have the autonumber in every table as the primary key and link these as relationships (although I don't think this is the correct way). I know they must be the same type to link, but other than that, what the the basic do's and don'ts, what should you link, etc?

Any help or suggestions are appreciated!
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
VERY quick summary...
1. Each table should have a primary key. Autonumber is typical, but some tables are better with data entry (ISBN for books, etc). This is a unique value and cannot be (1) duplicated or (2) Re-used if a record is deleted.
2. One table, one topic. For example, if you are taking bookings for a doctor's practice (assuming a single doctor here) you will have
(a) a Patients table with name, address, DOB and other contact details. Each Patient has their PatientID.
(b) a Booking Slots table with Day/Time increments. Each slot has a SlotID
(c) a Bookings table with these fields: BookingID (Primary key), PatientID (Foreign key, Number if PatientID is Autonumber, Text is PatientID is Text). SlotID (Foreign key for Slots, same data type as SlotID in the Booking Slots table).
The 3 table are related thus: PatientID (Patients) to PatientID (Bookings), and SlotID (Slots) to SlotID (Bookings). These are both One to Many relationships (the standard relationship type). Referential integrity should be enforced to prevent you from creating a booking for non-existent patients.
To create a booking, the PatientID and SlotID are entered into a new Bookings record.
Hope this gives the idea ... it's a big topic.

You might find a free download from the Microsoft Knowledge Base useful. Go to the KB, select your version of Access, and type Understanding Relational Design in the search area. Download the zip file -- it's a Word document that goes through the process of setting up the Northwind sample database that shipped with your Office installation.

Denis
 
Upvote 0

Forum statistics

Threads
1,221,700
Messages
6,161,371
Members
451,700
Latest member
Eccymarge

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top