Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
JonnyG
Starting Member
26 Posts |
Posted - 2005-12-14 : 16:15:08
|
| I always create database tables with an id column with an autoincrementing number.Does a table actually need this or can I remove this field if I don't refer to it?thanksJon |
|
|
jhermiz
3564 Posts |
Posted - 2005-12-14 : 16:36:10
|
quote: Originally posted by JonnyG I always create database tables with an id column with an autoincrementing number.Does a table actually need this or can I remove this field if I don't refer to it?thanksJon
You sound like an access guru :).An ID makes a row unique whether it be a singular primary key or some sort of composite key. You should always have some mechanism that makes a row unique by some sort of primary key.But you don't have to always make the primary key an auto incrementing big int / int identity column. I think robvolk has written a good article on candidates for primary keys. IIRC. Keeping the web experience alive -- [url]http://www.web-impulse.com[/url] |
 |
|
|
JonnyG
Starting Member
26 Posts |
Posted - 2005-12-14 : 16:38:19
|
| Yes, I have only recently moved to sequel server database programming...don't know why I didn't do it before, the robustness of it is marvellous! |
 |
|
|
jhermiz
3564 Posts |
Posted - 2005-12-14 : 16:46:53
|
quote: Originally posted by JonnyG Yes, I have only recently moved to sequel server database programming...don't know why I didn't do it before, the robustness of it is marvellous!
Its in this list: http://www.sqlteam.com/searchresults.asp?SearchTerms=primary+keysI think it's the first article thereJon Keeping the web experience alive -- [url]http://www.web-impulse.com[/url] |
 |
|
|
JonnyG
Starting Member
26 Posts |
Posted - 2005-12-14 : 17:16:17
|
| That's excellent. I've just removed a completely unnecessary id field from one of my tables and set the primary key as different field which holds unique data.thanks very much.Jon |
 |
|
|
JonnyG
Starting Member
26 Posts |
Posted - 2005-12-14 : 17:27:48
|
| Actually, looking at this again, on this particular table I will never need any uniqueness to any record in it. So, if I have no primary key and simply index the field and allow duplicates, is that OK? I really have absolutely no need to uniquely identify a record in this particular table. In lots of other tables I do, but in this one I have no need, so am I safe to have a table with No primary key?Jon |
 |
|
|
|
|
|