Database Design Question

Discussion in 'Databases' started by tin2mon, Oct 22, 2010.

  1. #1
    Hey guys,

    I'm designing a shopping cart e-commerce database.

    I basically want to have a table called purchase_order which provides the details of each order.

    I then also want a table called order_item which provides details or order items.

    My delima is this I want to have product tables that differ in what columns they have. Basically I want to have certain products that have certain attributes that the others don't have.

    So I could create different tables for each of these products but how do I associate it with the order_item table?

    How does the order_item table know which table to get the product from?

    Any help would be appreciated.
     
    tin2mon, Oct 22, 2010 IP
  2. flash_back

    flash_back Peon

    Messages:
    54
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    if I understand you correctly, just take unique ID for product and just associate whit this ID :) its silly to "create different tables for each of these products" :cool:
     
    flash_back, Oct 23, 2010 IP
  3. RonBrown

    RonBrown Well-Known Member

    Messages:
    934
    Likes Received:
    55
    Best Answers:
    4
    Trophy Points:
    105
    #3
    That makes the most sense. Unless you only have 2-3 different product types then a single table would be easiest to manage and set up. You can control what fields are used from this table for different product types through the code - this is much simpler. Using different multiple different tables for different products will make your code a mess, DB access a nightmare to manage, and your shopping cart difficult to maintain. Keep it simple and use the code rather than the database to manage the interface.
     
    RonBrown, Oct 23, 2010 IP
  4. Rajeev123

    Rajeev123 Peon

    Messages:
    100
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    good information..!!
     
    Rajeev123, Oct 27, 2010 IP
  5. CPACore

    CPACore Peon

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    There's one thing called relationship, you can build a relationship between two tables, and make primary key, secondary key, foreign key for each table based on your needs! The keys can be used for sorting, searching, and selecting!
    Good luck with that! :)
     
    CPACore, Oct 27, 2010 IP