1

How could I replicate Facebook's allocation of a unique ID to a vast range of resources? See: https://developers.facebook.com/docs/reference/api/

With Facebook every photo, person, event, page has a unique ID.

If I wanted to make every page have a unique ID all I would need to do is have a page table with ID that auto increments. But this is not what I want to achieve, I want to achieve a system like Facebook has, where every object ("resource") has a unique ID.

Rubens Mariuzzo
  • 28,358
  • 27
  • 121
  • 148

1 Answers1

0

MySQL has a UUID function; UUIDs are the generally accepted way to generate unique keys of this variety.

That said, using MySQL's UUID function will conflict with statement-based replication; if you are currently, or may in the future, use this method of replication, consider using whatever UUID-generating mechanism your language provides. As UUIDs are a standard, any reasonable programming language will have a mechanism available to generate them; for Python, for instance, this is the uuid module. For PHP, a uniqid function is available in the standard library, though this is not a standards-compliant UUID.

You might see this question, directly on-point for generating standards-compliant UUIDs from PHP.

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441