Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder primefalcon's Avatar
    Join Date
    Aug 2008
    Location
    /home/primefalcon/
    Posts
    678
    Thanks
    8
    Thanked 39 Times in 39 Posts

    Optimum Data types

    Im curious as the best data type to store Ip addresses and browser useragents

    Im thinking char 15 for ip's but not sure if there is some hidden pitfall there..... and not sure for the useragent maybe varchar 100 or something does anyone have any better idea's? or suggestions
    Last edited by primefalcon; 03-31-2009 at 10:59 AM.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    For IP I'd prepare for IPv6:
    IPv6 - char(39)
    IPv4 - varchar(15) / char(15)

    Useragents are trickier I have to admit. I generally use 100 myself, so long as you ensure that its truncated before going in. If you notice its too small, increase the size alloted for the useragent
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    Regular Coder primefalcon's Avatar
    Join Date
    Aug 2008
    Location
    /home/primefalcon/
    Posts
    678
    Thanks
    8
    Thanked 39 Times in 39 Posts
    Ahh thank you very much, that is exactly why I asked on here I forgot about IPv6 coming out, 39/15 if I plan on using one column to store both I might have to use varchar 39 then, unless I do some testing to see which is which and have 2 different column types which i wonder if that's worth it....

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    NP.
    Nope, I'd just go for the one. I'd make it up as a varchar(39) - the extra space will be no big deal for the time being.
    I messed up on that first post, I'd make it a varchar, not a char, since IPv6 can ignore leading 0's. I don't know what this will look like when it comes in over apache, but I figure the varchar is the way to go.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    primefalcon (03-31-2009)

  • #5
    Regular Coder primefalcon's Avatar
    Join Date
    Aug 2008
    Location
    /home/primefalcon/
    Posts
    678
    Thanks
    8
    Thanked 39 Times in 39 Posts
    Thanks for the help again,I guess I'm set for this


  •  

    Posting Permissions

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