mencargo
mencargo

Reputation: 111

Uniquely identify a big number with a smaller one (for data base index)

I have a "fact" transaction table where a ticket has several transactions, each transaction is a registry. To identify a ticket I have to group the table with 5 fields, (4 numbers and a date) that results in a 22 digit number, but to be able to use it effectively, it needs to be 19 digit max.

The total number of tickets that the table could store is a 10 digit number max.

How can I obtain a <= 19 unique number, from a 22 unique number composed by 5 numbers (including date transformed)?

It sounds like a hash to me, but I dont know much about them, and need it to be unique and numeric.

Upvotes: 0

Views: 48

Answers (1)

Oliver Charlesworth
Oliver Charlesworth

Reputation: 272557

I think you'll struggle to find a hash function that can take arbitrary (unknown) input data and guarantee you a unique output.

The simplest solution would just be to add an autoincrement field to your table.

Upvotes: 2

Related Questions