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

    Join Date
    Nov 2012
    Posts
    98
    Rep Power
    2

    Group "Similar" Items


    I am trying to link certain items with other related items. Examples of this would be a shopping cart when you want to checkout an item and it shows you a message "Other items that are similar to this one are:" - This is what I want to do, but don't know if there's a standard logic for linking them? Should I create another column for the product table with keywords? or should I link them by id, or something else?
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,301
    Rep Power
    7170
    There is not really standard logic for this. Figure out how you want to relate items from a business perspective, then once you have that defined you can build a database structure to support it.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  4. #3
  5. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,026
    Rep Power
    4210
    right, there's no standard logic for deciding what is "related"

    however, the structure to support a product-to-product relationship is pretty simple and supports all kinds of affinities

    you have a product table and a separate product relationship table which has exactly two columns, both of them product keys, each of them a foreign key to the product table, and both of them together as the primary key

    the nice thing is that a single row relating two products is directional

    for instance, when selling a bicycle, you want to suggest a helmet, but when selling a helmet, suggesting a bicycle would be risky (customer might abandon the cart right there in outrage)
    r937.com | rudy.ca
    please visit Simply SQL and buy my book
  6. #4
  7. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    98
    Rep Power
    2
    Originally Posted by r937
    right, there's no standard logic for deciding what is "related"

    however, the structure to support a product-to-product relationship is pretty simple and supports all kinds of affinities

    you have a product table and a separate product relationship table which has exactly two columns, both of them product keys, each of them a foreign key to the product table, and both of them together as the primary key

    the nice thing is that a single row relating two products is directional

    for instance, when selling a bicycle, you want to suggest a helmet, but when selling a helmet, suggesting a bicycle would be risky (customer might abandon the cart right there in outrage)

    This is all excellent information. Thank you both;

IMN logo majestic logo threadwatch logo seochat tools logo