I am currently trying to make a database for the place I work. We put partial social security numbers into the system to keep the patrons separate so we know who is who and I am trying to figure out if there is a way to make that easier. We are looking for a way to keep people from using the each other's social security cards [something that does happen] so while I understand how to make a single column unique, I was wondering if there is a way to make it so that all of the SSN columns would be unique, as there would be multiple.
Main SSN Spouse's SSN Children's SSNs
Sometimes there are up to seven or eight children and they all have to go in a separate column. So is there a way to make all of those SSN columns unique from each other? And if not in Access, is there a program that does it? We are currently using MyDatabase but I haven't found a way to make anything unique in there.
You are going at this the wrong way. What if you get a family with 19 children? You will need 21 SSN columns. Do you really want to have to modify all your forms and reports when a larger family than your design allows for shows up?
The uniqueness problem:
1.0 * 10^21
row comparisons. Indexing all 8 columns might speed this up a little, but at the expense of greatly increased storage, and vastly slower inserts and updates.In short, it is impractical to enforce uniqueness among 8 columns, let alone a reasonable maximum, like 21.
Aside: it is also probably a bad idea to store even partial Social Security Numbers in an unencrypted format. It makes uniqueness checks more likely to fail, and is probably against regulations.
My proposed fix:
This is a data design problem. What I suggest is instead of going horizontal (adding more columns), you go vertical (add related tables with more rows). For your main table, I suggest:
And then, your spouses table:
Finally, your children table:
Now, define indexes:
Next, you define table relationships:
Advantages: