What should be the leagth of int in a sql table where i store the facebook profile id? [duplicate]

六月ゝ 毕业季﹏ 提交于 2020-01-16 14:13:11

问题


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:

  1. ID: Database id for the pages (int 5)
  2. page_id: Facebook page id (bigint)
  3. page_name: Facebook page name (varchar 50)
  4. username: username of the page (varchar 50)
  5. likes: number of likes (int)
  6. Link: Link to the page (varchar 100)
  7. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!