SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot Jppr's Avatar
    Join Date
    Dec 2000
    Location
    Belgium
    Posts
    132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I recently asked some table descriptions of devshed.com's database. In "article" and "articlePage", I found that authorID is an int(6) where articleID is int(11). Then
    articlePageNumber is smallint(11).

    First of all, what is the difference between those types of int. In the manual I found:

    TINYINT[(M)] [UNSIGNED] [ZEROFILL]
    A very small integer. The signed range is -128 to 127. The unsigned range is 0 to 255.
    SMALLINT[(M)] [UNSIGNED] [ZEROFILL]
    A small integer. The signed range is -32768 to 32767. The unsigned range is 0 to 65535.
    MEDIUMINT[(M)] [UNSIGNED] [ZEROFILL]
    A medium-size integer. The signed range is -8388608 to 8388607. The unsigned range is 0 to 16777215.
    INT[(M)] [UNSIGNED] [ZEROFILL]
    A normal-size integer. The signed range is -2147483648 to 2147483647. The unsigned range is 0 to 4294967295.

    So if I understand correctly, it is just the size the integer could take.
    But, articleID is int (unsigned) so they can have more than 4'000'000'000 articles. Why do they think so big? And why do they use smallint for articleID. Does it have special meanings or something?
    What about tinyint, wouldn't that fit already?

    Secondly, what does that 11 and 6 between the parentheses mean? I don't get it. If I understand the manual correctly, it's the max number chars. But 11 chars in an integer is quite big no? A billion would fit in it!

    Please help me out!
    Thomas

  2. #2
    SitePoint Enthusiast Bartimeus's Avatar
    Join Date
    Dec 2000
    Location
    Norway, Trondheim
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are correct in your assumption. The number is the size of the int. So a int(11) would fit 11 digits.

    The different forms of ints have no other meaning then the limited number that may be stored in them. A tinyint can not contain as large a number as a int. That is obvious. Now why use a tinyint? Well it takes up smaler place in memory. So use a "smaler" int form then int if you know that your var will keep a limited number.

    Hope this help.
    Bjarte S Karlsen
    Roleplayer and webdeveloper with a high nerd factor.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •