Professional Web Applications Themes

MySQL question. - PHP Development

Try to create a MySQL tables and don't know how to decide the type of some fields: Key: SSN - use int/bigint/char ? PhoneNumber - int/bigint/char ...? The reason I asked is that I got a space used exceed the limit with just one row... Thanks in advance Regards, -Steven...

  1. #1

    Default MySQL question.

    Try to create a MySQL tables and don't know how to decide the type of some
    fields:

    Key: SSN - use int/bigint/char ?
    PhoneNumber - int/bigint/char ...?

    The reason I asked is that I got a space used exceed the limit with just one
    row...

    Thanks in advance

    Regards,
    -Steven


    Steven Guest

  2. #2

    Default Re: MySQL question.


    "Marcus" <JumpMan222aol.com> wrote in message
    news:3F066B10.5030909aol.com...
    > Steven wrote:
    > > Try to create a MySQL tables and don't know how to decide the type of
    some
    > > fields:
    > >
    > > Key: SSN - use int/bigint/char ?
    > > PhoneNumber - int/bigint/char ...?
    > >
    > > The reason I asked is that I got a space used exceed the limit with just
    one
    > > row...
    > >
    > > Thanks in advance
    > >
    > > Regards,
    > > -Steven
    > >
    > >
    >
    > Steven,
    >
    > I would just use char for both... I have stored phone numbers and just
    > use char(12) for 000-000-0000. If you want to use an integer type, int
    > would be the smallest size that would fit a 9 digit SSN... using
    > UNSIGNED should give you a range up to 2^32-1. I believe you would need
    > a bigint for a 10 digit phone number... again use UNSIGNED, as that
    > should give you up to 2^64-1. Hope that helps.
    >
    > Marcus
    >
    >
    Thanks Marcus !

    I have to use bigint for the phonenumber before I change it to char...

    -Steven



    Steven Guest

  3. #3

    Default Re: MySQL question.

    On Sat, 05 Jul 2003 05:29:21 GMT, "Steven" <xuemingcomcast.net> wrote:
    >Try to create a MySQL tables and don't know how to decide the type of some
    >fields:
    >
    >Key: SSN - use int/bigint/char ?
    > PhoneNumber - int/bigint/char ...?
    >
    >The reason I asked is that I got a space used exceed the limit with just one
    >row...
    Phone numbers are strings, not really numbers, so definitely use varchar.

    Depends how you store them, but even if you don't have characters like (, ), -
    and spaces in them, leading zeros are significant, so you don't want them
    disappearing if you used a numeric datatype.

    Don't know what the rules on SSNs are to say one way or the other, though.

    --
    Andy Hassall (andyandyh.co.uk) icq(5747695) ([url]http://www.andyh.co.uk[/url])
    Space: disk usage ysis tool ([url]http://www.andyhsoftware.co.uk/space[/url])
    Andy Hassall Guest

  4. #4

    Default Re: MySQL question.

    Message-ID: <lacdgv4k4u9tu9b4dnv1r496b72naeb8aa4ax.com> from Andy Hassall
    contained the following:
    > Phone numbers are strings, not really numbers, so definitely use varchar.
    >
    > Depends how you store them, but even if you don't have characters like (, ), -
    >and spaces in them, leading zeros are significant, so you don't want them
    >disappearing if you used a numeric datatype.
    My students always make this mistake. I usually ask them "could you use it
    in a calculation?" If no, it's not a number.
    >
    > Don't know what the rules on SSNs are to say one way or the other, though.
    Same applies, I'd say.

    --
    Geoff Berrow
    It's only Usenet, no one dies.
    My opinions, not the committee's, mine.
    Simple RFDs [url]http://www.ckdog.co.uk/rfdmaker/[/url]
    Geoff Berrow Guest

  5. #5

    Default Re: MySQL question.


    "Geoff Berrow" <$bl$ckdog.co.uk> wrote in message
    news:suqegvcdsjj33n61h1piqfgco989hmcsci4ax.com...
    > Message-ID: <lacdgv4k4u9tu9b4dnv1r496b72naeb8aa4ax.com> from Andy Hassall
    > contained the following:
    >
    > > Phone numbers are strings, not really numbers, so definitely use
    varchar.
    > >
    > > Depends how you store them, but even if you don't have characters like
    (, ), -
    > >and spaces in them, leading zeros are significant, so you don't want them
    > >disappearing if you used a numeric datatype.
    >
    > My students always make this mistake. I usually ask them "could you use
    it
    > in a calculation?" If no, it's not a number.
    > >
    > > Don't know what the rules on SSNs are to say one way or the other,
    though.
    >
    > Same applies, I'd say.
    >
    > --
    > Geoff Berrow
    > It's only Usenet, no one dies.
    > My opinions, not the committee's, mine.
    > Simple RFDs [url]http://www.ckdog.co.uk/rfdmaker/[/url]
    Thank you both and that is a very good point !!

    It took me almost two hours to figure out that I need bigint to store the
    phone number 9727121049, if I use int, it always changed to 214..... which
    I guess is the largest number for int. After I use bigint, it works fine,
    but I don't feel that is right though :)

    Thanks again.
    -Steven


    Steven Guest

Similar Threads

  1. php or mysql question
    By Jason Cooke in forum PHP Development
    Replies: 2
    Last Post: January 20th, 07:25 PM
  2. dbi::mysql question
    By rob merritt in forum PERL Beginners
    Replies: 0
    Last Post: January 2nd, 06:53 PM
  3. More of a mysql question
    By hokieghal99 in forum PHP Development
    Replies: 1
    Last Post: October 27th, 02:43 PM
  4. Question regarding PHP and mySQL
    By Me@lost_pls_help in forum PHP Development
    Replies: 1
    Last Post: July 27th, 09:57 PM
  5. A MySQL question
    By Zavaboy in forum PHP Development
    Replies: 5
    Last Post: July 14th, 11:26 PM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139