Results 1 to 9 of 9

Thread: Primary Key

  1. #1
    Join Date
    Feb 2004
    Posts
    2

    Unanswered: 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.

  2. #2
    Join Date
    May 2003
    Location
    Parsippany NJ
    Posts
    36
    If I am not taking ur sentance wrongly.
    There is no limitation on select statement. But defining PK is for uniquess enforcement.

  3. #3
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    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.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    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
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    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
    Last edited by Pat Phelan; 03-11-04 at 18:45.

  6. #6
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    Huh? What are you reading? And what's most important, - what are you smoking? And can I have one?

  7. #7
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    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

  8. #8
    Join Date
    Feb 2004
    Posts
    2
    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.

  9. #9
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •