Item category idcategoryname item table idnamecategoryname, what should I do with this product? Directly copy the categorynam... product category of the product category
Id categoryname
Item table
Id name categoryname (The problem is that the id of the product category or the categoryname of the product category is entered here)
Most people enter the id, but the product category is deleted. What should I do?
Directly copy the categoryname of the product category to the categoryname of the product table. What is the problem?
It doesn't matter whether this is anti-paradigm design.
Reply content:
Item category
Id categoryname
Item table
Id name categoryname (The problem is that the id of the product category or the categoryname of the product category is entered here)
Most people enter the id, but the product category is deleted. What should I do?
Directly copy the categoryname of the product category to the categoryname of the product table. What is the problem?
It doesn't matter whether this is anti-paradigm design.
In my opinion, you should enter the id to conform to the general principle.
If you directly enter the category name, it is not impossible, but there are at least two problems: 1. If the name changes, all records need to be updated; 2. From the query perspective, when you need to filter products by category, id filtering is faster than category name.
If the product category is deleted, you must search for the product table no matter whether you enter the id or category name in the product table. Otherwise, the data will be inconsistent.