Should I use a huge composite primary key or just a unique id?

Posted by Jack on Stack Overflow See other posts from Stack Overflow or by Jack
Published on 2010-03-25T17:00:45Z Indexed on 2010/03/25 17:03 UTC
Read the original article Hit count: 181

Filed under:

I have been trying to do web scraping of a particular site and storing the results in a database. My original assumptions about the data allowed a schema where I could use fairly reasonable composite primary keys (usually containing only 2 or 3 fields) but as time went on, I realized that my original assumptions about the data were wrong and my primary keys were not as unique as I thought they were, so I have slowly been expanding them to contain more and more fields. In fact, I have recently come to believe that their database has no constraints whatsoever.

Just today, I have finally expanded my a primary key for one of my tables to contain every field in that table and I thought now would be a good time to ask: is it better to add an auto-incrementing column that is just a unique id or just leave a composite primary key on the entire table?

© Stack Overflow or respective owner

Related posts about database-design