I have a table with 2 columns and 2 records. Column1 will never change but the Column2 might have chances that it will change but table will have only 2 records.
Column1
Missing
Invalid
Column2
\\sqlserver\destination\missing
\\sqlserver\destination\invalid
I am little confused here about the primary key that i wanna put on this table as there is no Id column. so which column i should have primary key? or do i have to add one more column with identity and put primary key on that?
Thanks
The criteria for choosing candidate and primary keys are:
uniqueness, irreducibility, stability, simplicity and familiarity
From what you have written,
Column1is definitely a candidate key. It has all 5 of the above criteria.Column2might be a candidate key if the two values in the table must always be unique. However, it is not stable soColumn1is a better key to choose for foreign key references to the table (primary key).You could create a 3rd numeric column. Since you constrain the table to 2 rows, it makes little difference whether the new column has a system-maintained sequence (identity attribute).
Column1has familiarity and the new column would not. At a logical level of discourse, bothColumn1and this new column are equally simple. Physically, a 7 character string is at least as large as a 64-bit number so a 32-bit number occupies less space.However, if you choose to add a new column due to physical size, I would consider a char(1) column with ‘M’ for missing or ‘I’ for invalid, which would still have all 5 criteria while occupying less physical space in referencing tables.