Would like to ask: how do I this data structure design to optimize thank you
CodePudding user response:
Edit view of total product data table, the businessman choose products is to choose the view, so businesses will share a database,CodePudding user response:
First of all, still need a business product table, or the business what product this information all don't know how to valueIf is 3 nf modeling, products and businesses is a many-to-many relationship, this time had to make a business with the product table to mark their relationship
Merchants product table: the ID, merchant ID, product ID, add time
Probably so several fields with respect to OK, if you need to query the businessman product information, need to merchants table, by means of table joins product table, the businessman product table to implement
MySQL database is stored, if the column a few cases, even if the large amount of data, are not very real storage
If you want to continue to use your pattern design, reduce the table joins, can consider through the merchant id hash partitioning,
Depots table, of course, is also OK, but the impact on the application layer will be larger,
CodePudding user response:
My personal advice is don't be afraid of table is too big, or the two tables: a table is commodity library, only to save this article 1000 data; Library another table is the merchant's goods, merchants chose 1000 data, just copy the article 1000 data, index, and caching, behind the table is too big to consider depots table,Because businesses may modify the commodity information, maintaining inventory, sorting operation, such as each merchants each commodity information may not be the same,