dcsimg
www.webdeveloper.com
Results 1 to 5 of 5

Thread: Best Data Types

  1. #1
    Join Date
    Jun 2008
    Posts
    21

    Best Data Types

    Hello,

    I'm new to databases and MySQL, and would very much like to know, what the most efficient/suitable Data Types would be used with the following data:?

    Account Details:

    • Email Address
    • Password
    • Email Updates?
    • Interested Sites (6 Check Boxes Max)


    Personal Details:

    • Title (Mr, Mrs, Miss, Ms, Dr)
    • First Name
    • Last Name
    • Image Title
    • Upload Image

    Address:

    • Property Name/Number
    • Street Name
    • Location
    • Town/City
    • Country
    • Postcode
    • Telephone
    • Work
    • Mobile

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,604
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Aug 2005
    Location
    The Garden State
    Posts
    5,634
    agree w/ Nogdog's cross post with just this point:

    use varchar almost exclusively, if it's free text. if it's an enumerated value (where you guarantee the length or something) you should be using enum. CHAR field always ends up w/ wasted memory.

  4. #4
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,604
    Hey, Chazzy, I was under the impression that CHAR was more efficient than VARCHAR if the field in question always or nearly always contained the max number of allowed characters (or very close to the max with larger fields). Thus, for something like a password field, CHAR might be more appropriate if you are storing the MD5 hash, for example, which will always be the same length. Is this correct, or is it a misunderstanding on my part?
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  5. #5
    Join Date
    Aug 2005
    Location
    The Garden State
    Posts
    5,634
    If you can guarantee that the value will always be 32 characters (for example) then you would use CHAR types. However, for any field that can have any # of characters up to N (say 255, for example) then you would use VARCHAR, so yeah your understanding's correct. most people will simply always use varchar, as it'll be easier to convert if need be.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles