Page 2 of 2 First 12
  • Jump to page:
    #16
  1. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,793
    Rep Power
    4331
    yes, those are the valid combinations

    and note, there are no duplicates

    in fact you don't even need the DISTINCT, and there still won't be duplcates
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  2. #17
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Posts
    456
    Rep Power
    80
    I decied to do it this way and was able to store the data I needed.
    Code:
    product attribute association table
    ===================================
    --------------------+---------------+-----------+-----------+
    prod_assoc_id | product_id | color_id | size_id  |
    --------------------+---------------+-----------+-----------|
    367                  | 1                 |    1,3        |    1,3        |
    368                  | 2                 |    1        |    3        |
          |
    --------------+------------+----------+---------------------+
    So I can store the sizes, colors and other attributes for each item as ids.
  4. #18
  5. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,793
    Rep Power
    4331
    Originally Posted by mallen
    Code:
        1,3
    huge mistake

    google First Normal Form
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  6. #19
  7. Lord of the Dance
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Oct 2003
    Posts
    4,164
    Rep Power
    2011
    Just curious.

    Why would you have a color and size table? Is that for any kind of (internal) database validation, e.g. by using FK? or something else?
    Do you have any special criteria when to leave out a surrogate key? few rows? highly unlikely for values to be changed?
Page 2 of 2 First 12
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo