2021年1月17日星期日

Database design for editable table

I have to design an application which will store products with default values, in a table called default_products .
This application will be used by customers (or users) who should be able to use the products from the default_products table, with their default value, but they should also be able to :

  1. edit and customize the default values of such product records for their own personal use - without affecting the product records of the other customers.
  2. add their own products, but these products should not be visible to other users.

One solution I could imagine would be:

  • one default_products table containing all the default products with their default values
  • one custom_products table with all the products crated by the users, and also a copy of the default product the user would have customized, and a boolean field like is_update to indicate if it is an update from a default_product record
  • A function which looks first for the updated product records from the custom_product table, then queries the default_products table and returns records from the default_product table + only the updated and custom products for that user from the custom_product table.

Any idea if this is any good? Or does anybody have any easier way to do?

https://stackoverflow.com/questions/65768219/database-design-for-editable-table January 18, 2021 at 10:51AM

没有评论:

发表评论