primary key in access?

  • Thread starter Thread starter monika
  • Start date Start date
M

monika

I have a table with fields as
1.id1 foreign key of table A
2.id2 foreign key of table B

how can I specify the same in access???? and also both in combination I want
it to act as a composite primary key.

can both these things be possible in access??? if yes how?

thanks
 
Monika-

To set multiple fields as the Primary Key of your table, open the table in
design view and hold down the Ctrl key as you click on the selector button
next to each field that you want in the primary key. Click the Primary Key
button on the toolbar to set it and then save your design.

To define these fields as foreign keys, select the Database window and then
click the Relationships button on the toolbar or choose Relationships on the
Tools menu. Add the three tables to the diagram and then drag and drop the
Primary Key from table A onto the id1 field in this table. In the
relationships dialog box, verify the related field names and decide whether
you want Access to enforce referential integrity for the relationship. Do
the same drag and drop from table B.

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out" (coming soon)
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
 
thanks a lot...it worked superbly. thanks!

just a query...while forming relationships I did "enforce referential
integrity" for all !
I hope I did correct thing?
thanks again!
 
When you ask Access to enforce RI, it won't let you add a row to your new
table unless matching values already exist for id1 in Table A and id2 in
Table B. Also, you won't be able to delete a row from Table A or Table B if
a matching value exists in your new table - unless you also chose Cascade
Delete.

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out" (coming soon)
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
 
Back
Top