3

Sequential IDs have pros and cons. UUIDs have pros and cons too. Why not use both for each table? (Let's say I have -and will have- no problem about storage space)

I could use:

  • UUID for exposition, display, export, API, etc.
  • Sequential ID for join, internal queries, convenience and debugging.

Is it a bad design idea? What are the pitfalls?

The benefit of using both would be to get the "pros" of each. There is an infinite discussion about "use seq id VS use uuid" and both have good arguments, so maybe I can use both and take benefits of each (depending on use case).

  • 2
    Unless someone with the actual experience of having taken this path can share their ideas, you will likely get only opinions, some, perhaps, justified better than others. Yours makes sense, to a degree. I would argue that exposing a UUID instead of a sequential ID means creating more traffic, because UUID is wider than even a bigint ID. But this site isn't about arguing, it's about solving problems. Are you envisioning any real problems in your current undertakings? Questions about hypothetical problems may still be fine, but they should present more research, to avoid unnecessary speculation. – Andriy M May 27 '16 at 10:05
  • 1
    Thank you. "Unless someone with the actual experience of having taken this path can share their ideas" -> I hope I will find her here, that's why I asked. I knew about about the risk of opinion-based response, but there is a "database-design" tag, so I think this kind of question may be asked on dba-se and get good answer (maybe not today)! Anyway, it's not really an hypothetical problem, I'm designing a database right now. Thanks, for your comment! – rap-2-h May 27 '16 at 10:14
  • 1
    @rap-2-h - as Andry said, your design is not bad per-se, it's simply not a common approach. If you think it's a good design, you'll need to do some thought experiments such as "what happens during an API lookup" or "how will I join rows for export without exposing the Sequential ID", to see if you can see any pitfalls. Ask about those specific things. – Max Vernon May 27 '16 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.