Hi,
I wonder if this great community can help me settle an argument or at least come to a happy compromise?
I've never been trained in database design. My teachers have been a handful of books & Tek-tips! My colleague though has years of database designing behind him & has a regimented, traditional approach. We've almost come to blows! Kidding, but I would like to hear peoples opinions on how you should approach setting the primary key in any given table.
I know there are three options:
1) Choose a field of unique data.
2) Choose multiple fields that should be unique, but can cover each other if not.
3) Create an AutoNumber column.
I always pick option 3, without question. Access created AutoNumber for that very purpose as far as I know. Anyway, I find it easier to deal with in relationships & coding. My colleague passionately disagrees & pursues option 1. At the end of the day, it's probably down to personal preference, but some of his comments make me wonder. I do have tables that don't need to link to others, but still have a primary key column. He says it's bad database design to just create one everytime. Maybe, but I don't trust other columns to be truly unique & prefer to play safe.
Should you always create a primary key without fail or can tables work fine without one at all? An AutoNumber can't be changed (a security I like), so if you choose a column containing unique data that is altered later, are dependant relationships at risk? Should you always aim to use an integer as the primary key or is text ok?
Over the years I've read great stuff here about designing tables, but not really forcing a choice. I seem to remember seeing something about corrupted data because of poorly chosen keys, but maybe I dreamed it!
I'd appreciate your comments!
I wonder if this great community can help me settle an argument or at least come to a happy compromise?
I've never been trained in database design. My teachers have been a handful of books & Tek-tips! My colleague though has years of database designing behind him & has a regimented, traditional approach. We've almost come to blows! Kidding, but I would like to hear peoples opinions on how you should approach setting the primary key in any given table.
I know there are three options:
1) Choose a field of unique data.
2) Choose multiple fields that should be unique, but can cover each other if not.
3) Create an AutoNumber column.
I always pick option 3, without question. Access created AutoNumber for that very purpose as far as I know. Anyway, I find it easier to deal with in relationships & coding. My colleague passionately disagrees & pursues option 1. At the end of the day, it's probably down to personal preference, but some of his comments make me wonder. I do have tables that don't need to link to others, but still have a primary key column. He says it's bad database design to just create one everytime. Maybe, but I don't trust other columns to be truly unique & prefer to play safe.
Should you always create a primary key without fail or can tables work fine without one at all? An AutoNumber can't be changed (a security I like), so if you choose a column containing unique data that is altered later, are dependant relationships at risk? Should you always aim to use an integer as the primary key or is text ok?
Over the years I've read great stuff here about designing tables, but not really forcing a choice. I seem to remember seeing something about corrupted data because of poorly chosen keys, but maybe I dreamed it!
I'd appreciate your comments!