I have a question about primary key,
I would like to create a database by importing from an Excel sheet, but the data is not good enough, now we have some empty and duplicated fields and I want to create a composite primary key on the table so that later that no duplicates records and blank field will happen.
But for some of the previous records we cannot find those information for the blank fields, but we still want to keep them in the table. Is there any way that I can create the PK to inforce referencial integrity only for future entered recods but still keep the old records the same as it was.
Yeah - a primary key cannot logically (in all senses of the word) contain nulls.
You can, however, define a unique composite index and specify that Nulls are to be ignored. Any key containing a Null won't be added to the index. Closest you can get unless you get rid of the offending records.
Originally Posted by Codd
The values in a row are dependant on the key, the whole key, and nothing but the key, so help me Codd
A brief flicker of a thought - SQL Server has a NO CHECK option when creating an index programmatically (all previously entered data is not checked against the constraint). JET might have the same. I would doubt it... and even if it did I am not sure that it would allow you to apply this when creating a primary key.