RE: Primary Key use
Dear Craig
Thank you for attending Excel and Access courses. I hope you enjoyed them and they were beneficial to you.
If believe you asked this question when you did Access Intro where we didn’t cover the practical aspect of using the primary key to link the two tables. We only looked at the theoretical side of using Primary key.
Since then I assume that you have done Access Intermediate where you may have learnt how to create relationships between tables by the help of Primary key.
Primary key is the field that contains data that is Unique. A common example of this would be in a Bank database in Customer’s Table the primary key would be Account Number.
Primary key helps in identifying a specific record within a table.
There are various type of relationships namely one-to-one, one-to-many, and many-to-many. The most common type is one-to-many so let me take you through this.
Step 1: In access open the database that you wish to establish relationship between tables.
Please ensure that you have a field with the same name on both tables. It should be a primary key on the main table. In the other it doesn’t need to be primary (this is known as Foreign Key)
Step 2: In the Database window click the Relationship button on the toolbar or choose Tools > Relationships…
Step 3: You may get a Show Table window which will enable you to choose the tables that you wish to create relationship for. If you do not see the show table window then please click on the Show Table Window button on the toolbar. You can also click on Relationships > Show Table…
Step 4: Choose the two or more tables you want to create relationships for and press Add button.
Step 5: Drag the primary key of the main table and drop it to the foreign key of the other table.
Step 6: In the Edit Relationship dialog box you can put tick on the enforce referential integrity to make sure that the records in both the tables are valid and so that you don’t accidentally delete or change the related data.
Step 7: Click Create.
I hope this helps in answering your question.
If this posting has helped in answering your query then I would request you to mark the posting as Resolved . If, however, it hasn’t and you need further clarification then please press the reply button and ask for further clarification with your specific question. In case you have a related question then please ask the question as a separate posting.
Kindest Regards
Rajeev Rawat
MOS Master Instructor 2000 and 2003