Monday, March 12, 2012

Primary Key

In a recent course on database programming using Microsoft Access 2002. I noticed that the text entitiled New Perspectives Microsoft Access 2002 stated that a primary key could only be used once per table. But If I am not mistaken could one use the select key to select more than one primary key within a table.If I am not taking ur sentance wrongly.
There is no limitation on select statement. But defining PK is for uniquess enforcement.|||In SQL Server or MS Access, only one Primary Key can be defined on a table, although this Primary Key may be a compound key consisting of more than one column.

A SELECT list can contain as many columns as you wish, regardless of whether they are primary keys.|||you can have only one primary key per table

that part is absolutely true

your comment "could one use the select key to select more than one primary key within a table" is slightly inaccurate, but you are on the right track

yes, you can, in the Design View for the table, select more than one column and make them the primary key

there can be only one primary key, but it may be a composite key, consisting of multiple colulmns|||Not the way the definition works... There should be one or more Candidate Keys (a column or columns that uniquely identify each row within the table). One of those Candidate Keys becomes the Primary Key just because the data modeler said so, by definition all of the rest of the Candidate Keys become Alternate Keys.

-PatP|||Huh? What are you reading? And what's most important, - what are you smoking? And can I have one?|||Originally posted by rdjabarov
what are you smoking? And can I have one? I don't smoke, so you'd better have two, they're small!

-PatP|||Pat and r937,

First of all thank you for your replies and I did do this selection in the design view while having the shift button selected.|||Ah-ha! I was thinking from a data modeler perspective. You were asking from an Access GUI user perspective. Fundamental communication error there!

Yes, Access allows you to select more than one column to become part of the primary key. The columns don't even have to be next to each other, you can use the first, third, fifth, and tenth columns if you like.

-PatP

No comments:

Post a Comment