Results 1 to 3 of 3

Thread: composite unique constraint or composite primary keys

  1. #1
    Join Date
    Mar 2005
    Posts
    2

    Post composite unique constraint or composite primary keys

    Dear all,

    I have a table comprise of :
    CompanyName+Region+District+Area+Location which would make the identity of the table.

    I'm considering whether to use composite primary keys with the fields above or adding a new auto-numbering field as the primary keys and make those fields above be composite unique keys.

    In fact, I have no experience coding an application with tables with composite primary keys.

    I code in ASP.NET-VB.

    do give me advice or suggestions, or perhaps share your experience.

    thank you in advance.

    Best regards,


    ~salle~

  2. #2
    Join Date
    Feb 2003
    Posts
    1,048
    There are times when a composite primary key is good to use, but this is not one of them.

    Using this many fields, especially when some or all of them are string fields, would be bad on performance. This would make the clustered index very large and slow. Also, in SQL Server each additional index is based off of the primary key index, so any other indexes would be large and slow.

    Use an identity field for your primary key in this situation.

  3. #3
    Join Date
    Mar 2005
    Posts
    2

    Smile

    Thank you Rawhide.
    I gave it a try. Unique constraints work better.

Posting Permissions

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