Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What data type do you use for storing IDs?

Why is there a minimum character count for posting questions? o.O

Do you use int, bigint, tinyint, whatever?

It seems like a small thing I guess, I was just wondering what the usual practice is

like image 324
thesmallprint Avatar asked Jan 24 '23 01:01

thesmallprint


1 Answers

It all depends ... my favorite answer to a question! =)

Most of the time we use Guids. While they are larger, size-wise, than int, tinyint and so on, I like the fact that my business objects can know what the value is before inserting records into the database.

At other times I may use strings, for things like customer id, where it might need to be easily recognized when working with the database.

like image 80
mattruma Avatar answered Mar 03 '23 21:03

mattruma