By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,842 Members | 2,154 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,842 IT Pros & Developers. It's quick & easy.

multiple field primary key in Access 2003?

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
-----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.