Primary Key in SQL server

Results 1 to 3 of 3

Thread: Primary Key in SQL server

  1. #1
    Join Date
    Dec 1969

    Default Primary Key in SQL server

    is it mandatory to keep one primary key in all tabels in SQL server 2000<BR>how the performance is hit when primary key is not used?<BR>thanks

  2. #2
    Join Date
    Dec 1969

    Default RE: Primary Key in SQL server

    no, it&#039;s not mandatory, and the main problem with omitting it isn&#039;t performance but data integrity (though performance could be degraded in a number of cases - depends what you&#039;re doing)<BR><BR><BR>j<BR>

  3. #3
    Join Date
    Dec 1969

    Default Primary key often a MISTAKE

    Consider this situation:<BR><BR>TABLE: Courses<BR> courseID : autonumber, PK<BR> courseName : varchar<BR><BR>TABLE: Students<BR> studentID : autonumber, PK<BR> studentName : varchar<BR><BR>TABLE: CoursesTakenByStudents<BR> courseID : FK to the Courses table<BR> studentID : FK to the Students table<BR><BR>You do NOT WANT a primary key on that CoursesTakenByStudents table! You might want to create an index on one or both of the fields, but since both can contain non-unique values those indexes cannot be primary key indexes. There is no possible purpose served by having a primary key on that table; at least, none that I can see.<BR><BR>And yet you would be amazed at the number of people who will blindly put an autonumber PK on that table. Ask them why, and they don&#039;t have the foggiest notion. There&#039;s no logical place to use the silly thing (in any other table, that is), so why?<BR><BR>

Posting Permissions

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