What is the relationship between commodity classification and commodity table?

Source: Internet
Author: User
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.

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.