469,588 Members | 2,688 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,588 developers. It's quick & easy.

multiple field primary key in Access 2003?

Joe
I have a table with a student id and course id. I would like to make
both fields the primary key since a student can have multiple course
ids but I do not want duplicate records.

How would I go about creating the multiple field PK in Access 2003?
Thanks!

Nov 13 '05 #1
1 13776
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Easiest:

1) Open the table in design view.
2) Drag over the record selectors (square blocks to the left of the
column name) of the 2 columns you want as PKs; or, hold down Ctrl &
click the record selectors of the columns you want as PKs.
3) On the main menu click Edit > Primary Key.
4) Close & Save the table.
a) If there is duplicate data in the PK columns you will not be able
to save the new table design.

SQL DDL:

ALTER TABLE table_name
ADD CONSTRAINT PK_table_name (StudentID, CourseID)

Put the above in a Query's SQL view & run it. Number 4), above,
applies: the DDL statement will fail.

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQfHGNYechKqOuFEgEQJ8VgCbB/eeBdagCUjEQG/jR+J1snlAwQIAoPt7
cd/TKbAKgkv7dM4eREPoNy75
=ygN8
-----END PGP SIGNATURE-----
Joe wrote:
I have a table with a student id and course id. I would like to make
both fields the primary key since a student can have multiple course
ids but I do not want duplicate records.

How would I go about creating the multiple field PK in Access 2003?
Thanks!

Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by suzanne shelton | last post: by
5 posts views Thread by rdemyan via AccessMonster.com | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.