SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    USA
    Posts
    633
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Query Help Please

    HI All

    I have been battling with a query that will assist me .

    My previuos thread http://www.sitepoint.com/forums/show...=1#post1647117 under the php section has helped abit as well.

    What I have is a html form with a set of health symptoms,that will be inserted into a database using implode() in php, I will extract the data using explode() in php.

    Now if I take a condition like diabetes, when someone fills in a assessment , I want to know what other symptons were filled in together with diabetes, and how often.

    Basically I want to be able to extract the most common symptons that were selected together with diabetes.

    See my post above if unclear.

    Please help me , I need this for my college project.

    Thanks
    DIdi

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,322
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    well, i hate to break it to you, but while implode and explode are wonderful programming functions, storing more than one value in a column is very poor database design practice

    design your database table to have one symptom per row -- the key of this row will be what determines multiplicity of symptoms

    read this article: Fundamentals of Relational Database Design
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Zealot CdeMky's Avatar
    Join Date
    Sep 2004
    Location
    United States
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have to agree, you need to break up those column entries before you do anything else, this should make it much easier to mine the statistics you want out of your DB.

  4. #4
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    USA
    Posts
    633
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the reply,

    If i go ahead and break it up, will I not have a table that is not normalised.

    example:-

    I buy 4 products, using an array I would have :-

    cust_id products
    1234 [producta][productb][productc][productd]

    Now if I have each item on a single row I will have

    cust_id products
    1234 [producta]
    1234 [productb]
    1234 [productc]
    1234 [productd]

    Am I correct in saying this, will this not result a databse that is not normalised.

    I am only asking, I am one gal that is still learning,I donot know much about these stuff.

    Please help

    Didi

  5. #5
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,322
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    you are correct, this will not result a databse that is not normalised



    the example with the 4 rows IS normalized

    all 4 values in a single row is NOT normalized

    you always want to go for the normalized solution

    here's another example: The effect of normalization on query simplicity (site registration may be required, but it's free)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


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
  •