Unique Id Columns
Posted: Wed Oct 13, 2010 7:32 pm
I just wanted to ask for peoples preferances on this topic. Should every database table have a unique "Auto Increment" column?
i.e. I have 2 database tables, one is "users" it features user account information including (userid which is unique & auto increment). The other is "user_settings" it features the users account settings. In "user_settings" I refer the other tables userid. Userid is unique to each row as each user only has 1 set of settings.
Now, my question is, should I have a column in "user_settings" called settingid and make it unique and auto increment, or is the unique userid column enough?
I guess it is a matter of preference, but I wanted to ask what you alls thoughts are.
i.e. I have 2 database tables, one is "users" it features user account information including (userid which is unique & auto increment). The other is "user_settings" it features the users account settings. In "user_settings" I refer the other tables userid. Userid is unique to each row as each user only has 1 set of settings.
Now, my question is, should I have a column in "user_settings" called settingid and make it unique and auto increment, or is the unique userid column enough?
I guess it is a matter of preference, but I wanted to ask what you alls thoughts are.