Find a Natural Key in a dataset
-
27-04-2021 - |
Question
I inherited a table with about 40 columns and about 1400 rows. Unfortunately, the original designers didn't include an identifiable PK in the table so I'm assuming they used a natural key with a combination of 4 or 5 columns. However what those columns are are unknown.
Is there any easy way to determine this or do I need to sit down and start trying to reduce it via select statements?
Solution
I ended up taking the approach of excel and filters and narrowing down items until I was left with one entry. After that I then took the approach of making sure those fields would always bring back a unique row.
To do that I went back to the DB and counted the distinct rows when just selecting those fields.
It took a bit of guess and check but it ended out working well.