How to design the order table scheme of electric business system better

Source: Internet
Author: User
Tags one table
Topic Background:
Before doing electric business operation, intend to change careers to do development, participated in a few interviews, almost every family will ask the large amount of data when the solution. Don't discuss the rationality of this question for the time being, if there is demand, then strengthen it yourself. Therefore, based on the current individual to do a system, plan to large data volume to do expansion design.

Business scenarios involved:
(1) There are multiple sellers (seller) in the market to view and process orders containing the seller's goods (order)
(2) Buyers (user) can view the tracking of their own orders

Order table design and query-time processing logic
Programme 1 (initial programme)
(1) The original order form according to the buyer ID take the mode of the table
(2) New buyer and Order mapping relationship table (also will be very large data, can be OrderID to take the model table)

Query processing logic:
1 Buyers inquiries all their orders: According to UserID take the model to find the corresponding order form, take the data
2 buyers in accordance with the order number of orders: According to OrderID from the buyer's order map to obtain UserID, and then still follow the UserID modulo to find the corresponding order form
Problem: After this split, the seller-related orders are split in more than one table, the seller to view their orders or to scan all the data

Programme 2 (Revision of programme 1)
The original order also according to the seller ID modulus of the table, and then set up the seller and order mapping relationship
Problem: Although the scheme can achieve the set of business logic, but order data to save two copies, to maintain two mapping table

Programme 3 (Revision of programme 2)
Learn Taobao's order system design, split the order into buyer's library, seller's library, message-oriented middleware for order synchronization (similar to the scheme 1, 2 of the buyer, the seller of the table), it seems that is not concerned about the order data redundancy, but did not want to understand how to follow the order query, so the design for reference 3
(1) According to the userid to take the mold table
(2) According to the Sellerid to take the mold table
(3) According to the OrderID to take the mold table
Compared to scheme 1, 2, less maintenance of a table, but there are two data redundancy
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.