#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    161
    Rep Power
    12

    Understanding a table structure


    Hello all,

    So I have this app that creates a MySQL database. I'm looking to tweak it but I don't understand something.

    In this particular table "clothes", the columns are names of the clothes type. So you have "t-shirts", "sweaters", "jackets" etc etc. In those columns you have values like {"Color":"red", "Size":"L", "Fabric":"Cotton"}

    The row is set as a longtext and contains a lot of data than just the example I gave above, like designer, style, year, season....

    Could someone breifly explain why they chose to lay it out this way rather than columns reading "Color", "Size", "Fabric", "Type"? Is it because it may be faster or more efficient in some way?
    Last edited by lunatic; April 17th, 2012 at 12:22 PM.
  2. #2
  3. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,540
    Rep Power
    1906
    I doubt there is any efficient received, as you have to do more work in the application instead to "extract" the data.

    I will not like the look of that query which can extract "all or just a specific cloth type of size Large".
  4. #3
  5. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,030
    Rep Power
    4210
    Originally Posted by lunatic
    Could someone breifly explain why they chose to lay it out this way
    briefly?

    because they were idiots
    r937.com | rudy.ca
    please visit Simply SQL and buy my book
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    2
    Rep Power
    0
    Maybe because that syntax make it easier to load that string into a javascript of php object (not sure about php, but looks like a valid JSON string) That said, I still think it's a bad idea to take such shortcuts. Usually sacrificing architecture for less LOC bites back badly in the future.

    BTW this is a MS SQL subforum not MySQL so I reckon the thread should be moved
  8. #5
  9. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,030
    Rep Power
    4210
    Originally Posted by Zarium
    BTW this is a MS SQL subforum not MySQL so I reckon the thread should be moved
    quite right, and thanks, i shoulda spotted that the first time through here

    thread moved

    r937.com | rudy.ca
    please visit Simply SQL and buy my book

IMN logo majestic logo threadwatch logo seochat tools logo