This is a discussion on PK within the SQL Server forums, part of the Microsoft SQL Server category; --> I have seen some look-up tables have no primary key because there is a null or " " value ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I have seen some look-up tables have no primary key because there is a null or " " value in them. Since every table should have a Primary Key, can anyone educate me how can I handle null or " " value, in the code level? I am avoiding using Surrogate key. Thanks, J P.S. Null or " " value is "Unknown". |
| |||
| J wrote: > I have seen some look-up tables have no primary key because there is a null > or " " value in them. Since every table should have a Primary Key, can > anyone educate me how can I handle null or " " value, in the code level? I > am avoiding using Surrogate key. > > > > Thanks, > > J > > > > P.S. Null or " " value is "Unknown". Nothing technically wrong with ' ' as a key if that makes sense to your business. If you have nulls then eliminate them either by decomposition or by encoding the unknown value as something else. There is no excuse not to have a candidate key. -- David Portas, SQL Server MVP Whenever possible please post enough code to reproduce your problem. Including CREATE TABLE and INSERT statements usually helps. State what version of SQL Server you are using and specify the content of any error messages. SQL Server Books Online: http://msdn2.microsoft.com/library/m...S,SQL.90).aspx -- |
| ||||
| J, I suspect that if you have NULL in the colum or a column of what should be the natural key to a table that you have bad data or a non-normalized table. Fixing bad data is usually easier than fixing bad design. Adding a surrogate key will do nothing to protect the integrity of the business data in the columns in question. Good luck -- Mark D Powell -- |
| Thread Tools | |
| Display Modes | |
|
|