BONSAMURAIS / schema

Relational database schemas for BONSAI
BSD 3-Clause "New" or "Revised" License
0 stars 2 forks source link

smarter ids #23

Open BenPortner opened 4 years ago

BenPortner commented 4 years ago

In the current schema, IDs are implemented as INTs. I think they should be strings. The IDs should then be hashes representing the values of the fields. This has two advantages:

1) no integer overflow (although this might not be a problem if the int has enough bits) 2) automatic duplicate detection: if the hashes match, the content of the entry matches and addition to the database is prevented

cmutel commented 4 years ago

Debate on natural versus surrogate keys is long and more long; for the time being, can we leave it as it is, and revisit if there is a pressing need for change?

BenPortner commented 4 years ago

ints won't overflow until 2 billion (21474836478, to be precise), and can be migrated to to bigint if necessary.

Wow, yeah that should be enough unique keys for now. Case closed.

There could be cases where duplicate data is desired.

Just out of curiosity: Can you give me an example where it makes sense to have duplicate rows?