How to store complex product/order data in MySQL?

后端 未结 2 913
暖寄归人
暖寄归人 2021-01-24 07:44

I\'m working on an order system for my online shop. I have 2 tables:

  1. products, storing info about products
  2. orders, storing general id\'s & infos of cu
2条回答
  •  天涯浪人
    2021-01-24 08:14

    Depends on your goals for your cart. For instance, do you want to allow guest purchases? i.e. where a user does not need to login in order to make a purchase?

    The attached image is a design I have been working on and it goes like this:

    1. A visitor selects products from the site and adds these to a session cart (just a place to temporarily store the products, their quantities and their prices etc.)

    2. Once the customer is ready to check out, we create the order, the order person and the person_address (where the product must be delivered to) and add the items to the order_item table. All this information is added by the customer in the checkout page.

    3. The final step is then to offer the payment methods: paypal, credit card, etc.

    What I like about this design is that users have no obligation to register with us. Order_person acts as a kind of interface between users and orders. If do register, we simply link order_person to the user table...

    I have included a sample front end of the checkout page too.

    Product Order Database Design

    enter image description here

提交回复
热议问题