I am having a problem choosing the variable types for database table.
Can someone please give me some general guidelines as to how to choose the types? The following are some of the questions I have —
-
What should an userid be? An INT seems small as the design should take large number of users into account. So if not INT what else? BIGINT? VARCHAR? Am I not thinking straight?
-
When should I choose varchar and text and tinytext, binary?
I searched online and did not find any helpful links. Can someone point me in the right direction? Maybe I need to read book.
Update for 2013: The internet now has roughly the same number of users as a signed 32-bit integer. Facebook has about a billion users. So if you’re planning on being the next Google or Facebook, and you definitely won’t have time to re-engineer between now and then, go with something bigger. Otherwise stick with what’s easy.
As of 2010:
An int seems small? Are you anticipating having 2,147,483,648 users? (For the record, that’s like 1 in 3 people in the world, or 400 million more than the total number of people who use the internet; or 5 and a half times more users than Facebook).
Answer: use an int. Don’t overthink it. If you get in a situation where our old friend the 32-bit integer just isn’t cutting it for you, you will probably also have a staff of genius college graduates and $5b capital infusion to help solve the problem then.