开发者

Generating unique identifiers mostly like UUID but with namespace checking

I am working on the design of a database which will potentially hold millions of records. Each record will have only a few pieces of data (say, about fifteen fifty-character strings).

The different records belong to the same class of object, but from a different "source"; a namespace would capture this relationship. For instance, object 1 belongs to namespace 1, object 12321 to namespace 2, etc.

I want to design the unique identifiers for these records.

If I were to use UUID version 5, generating the UUID attached to the namespace would be trivial. However, there is no way of knowing wether a given UUID belongs or not to a given namespace.

Then I thought of an algorithm along the lines of Luhn's Algorithm (the one used for credit card numbers) which checks wether a number is "correct" or "not".

How would you go about this?

Requirements:

  1. All the UUID requirements
  2. Ability to check that a UUID belongs to a given namespace
  3. 开发者_C百科


If you store the namespace in the same table and index it, one simple query will tell you if the uuid exists in a given namespace. But aren't uuid suppodes to be unique anyway? So duplicates should not exist.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜