Home>

Thank you very much. Let me ask you a question about database design.

What i am wondering about

As the title says.
Currently there is a table calledProducts. I'm wondering if we can divide this into two tables:Pre-purchase itemsandPurchase items.
By the way,Purchased productsis simply a data item withbuyer_idadded to theProducts before purchasecolumn.

Don't split the table

= Itembuyer_idis NULL in the pre-purchase table

  • Merit
    Simple structure
  • Disadvantages
    Search from the big table bother to search purchase history
Separate tables

= Itembuyer_iddoes not exist in the pre-purchase table

  • Merit
    When searching the list of products, it is not necessary to search for useless lines. (The same goes for the purchase history list)
  • Disadvantages
    I did not come up with anything. In other words, will you clearly explain the difference between the two tables to the people in charge of View? . .
Other thoughts

Purchased products are based on the premise that they can only be viewed by buyers and sellers, butpurchased products can also be referenced (buyer If there is an implicit understanding ofthat is usually, the question is resolved. How is it actually?

  • Answer # 1

    Let's find out what kind of demand (try writing SQL).
    If you want to get pre-purchase information and post-purchase information at the same time and there are many requests, it is better to stop because the performance is bad because you have to use UNION if you separate the table.

  • Answer # 2

    Does the product before purchase look like a cart?
    It would be better to divide it.
    If you think that the table will not be erased after purchase, it will be frequently updated to the table that grows steadily.