1

My coworkers and I are about to get started building a web app. We got around to discussing id's for our database table rows. We were discussing the pros and cons of bigints vs char(32) unique strings vs both.

It seems like every single ORM i see relies on integer ids. I've always used integer ids for my side projects.

My coworker has apparently run into problems when using integer ids. In our application we do a lot of importing data from things like excel spreadsheets. He claims its much easier to insert/replace/relate data when you're not fighting the database's internal auto-increment mechanism. That makes sense.

It strikes me as odd that i haven't seen many people using unique string identifiers in place of auto-incrementing ids though.

I see facebook and twitter using what looks like bigints in their urls. It seems careless to expose your database id field in your public url though.

Reddit seems to use 6 alpha-numeric string identifiers for their links to comments.

Is there a common strategy or a resource i can read to learn more about the different approaches?

David
  • 10,418
  • 17
  • 72
  • 122
  • You may like to look at the many posts debating Surrogate Vs. Natural keys; http://stackoverflow.com/search?q=surrogate+key – Alex K. Jan 14 '14 at 16:58
  • I think i've already decided on using surrogate keys. A big int and a char(32) have no business meaning and therefore are surrogate keys from what i understand. I guess i'm asking, which flavor of surrogate key should be used. – David Jan 14 '14 at 17:08
  • _"fighting the database's internal auto-increment mechanism"_ - Just because PK is integer doesn't mean it has to be auto-incremented. – Branko Dimitrijevic Jan 15 '14 at 00:32

0 Answers0