Home > Archive > MS SQL Data Warehousing > March 2006 > database design: primary keys









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author database design: primary keys
Bill H

2006-03-28, 3:23 am

Is it recommended to keep primary keys limited to a single field?

I have an account_id in all tables, and I wanted to make the rec_id in all
tables unique within an account_id, so the primary key would be based on
account_id + rec_id. I like the idea of each Account starting at 1 for
their rec_ids, though I know this is not necessary. I also want to do this
in case I need to break out all recs in all tables for a particular account
or customer. Initially, all customers will be hosted in one database for a
web app. But there will opportunity for that customer to later host their
own data, at which point, it be real easy to break out their data.

The downside is that all my queries need to include account_id. Will this
impact performance on SQL much greater than having a single field primary
key ? Is there a recommended design for this ?

It will work either way, I know. I'm just trying to get opinions on the
preferred method out there.


Thanks...
Bill


Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2009 droptable.com