问题
Most often i work with cms but did not worked with sql directly too much before. I am making a facebook page directory where i am saving page ids the length of facebook page id is 10-13 digit sometimes. So what types of int i should use. I am thinking about BIGINT
but what should be the length of it ?
Here is the table visually. I would be glad if you can advice the length of the fields.

Here is the datatype and length i comeup with. But i am confused if these are efficient:
- ID: Database id for the pages (int 5)
- page_id: Facebook page id (bigint)
- page_name: Facebook page name (varchar 50)
- username: username of the page (varchar 50)
- likes: number of likes (int)
- Link: Link to the page (varchar 100)
- Time_added: current timestamp
回答1:
Correct, you'll need a BIGINT
: http://dev.mysql.com/doc/refman/5.6/en/numeric-types.html.
I'd recommend longer lengths for your VARCHAR
fields. It won't hurt anything, and URLs in particular can get very long. I'd probably bump up the two 50-character fields to 100, and allow for 1,000 characters in the Link field.
回答2:
As you don't have control over what Facebook might do in the future, I'd use a type that is least sensitive to change.
As you won't be doing an arithmetic manipulation to the page_id, I'd store it as a varchar.
回答3:
the easiest thing is to treat those IDs as string or varchar with 15 characters. using php it can cause problems when working with 64-bit integers.
the performance difference is negligible!
来源:https://stackoverflow.com/questions/6139940/what-should-be-the-leagth-of-int-in-a-sql-table-where-i-store-the-facebook-profi