Design Ideas for different types of online store product Databases

Source: Internet
Author: User
The problem was raised: Online Shopping Malls classify products in many ways, and different classified products have different attributes, such as: CUP, memory, motherboard, hard disk, etc, clothing attributes include cloth, size, color, etc. How should we design the product table and product category table to meet the differences between different types of products? Solution: Production

The problem was raised: Online Shopping Malls classify products in many ways, and different classified products have different attributes, such as: CUP, memory, motherboard, hard disk, etc, clothing attributes include cloth, size, color, etc. How should we design the product table and product category table to meet the differences between different types of products? Solution: Production

Question: The online marketplace classifies products in many ways. Different products have different attributes, such as: CUP, memory,
The main board, hard disk, and so on. Clothing attributes include: cloth, size, color, etc. Then how should we design the product table and product category table to meet the requirements?

What are the differences between different types of products?

Solution:
Product Category Table Design
The first design concept: tree structure, recursive form, can be used to classify products, as long as you like, tree structure in the database design
It is often used. For example, the functional menu table is a simple product category table.



Note: The parent category ID is the foreign key of the table and is associated with the category ID of this level. In this way, the product can be classified in N. This design
The idea is very flexible and is the most commonly used in unlimited classification.

The second design concept: Define N category tables and associate them,


Note: No one in the project will use this design because the product category is not fixed and it is difficult to determine it during database design.
The number of category tables is not flexible.

2. Product Table Design
The first design concept: Reserve N fields in the product table and insert data directly when used,



Feasibility: many fields are redundant, and you do not know how many fields are required. The data type cannot be determined. The feasibility is relatively low,
This design also has its advantages, that is, the number of tables is small and I cannot find other advantages.
It will not be used either.

The second design concept: Before referring to this design concept, we must first understand that the data table can be divided into two structures: horizontal table, that is, we often use
The other is the vertical table. We usually use a small number of tables in this structure, so today I also ask other people to know
With this table structure.
What is a vertical table? What are its advantages and disadvantages? The comparison between the two images may be clearer.

Horizontal table structure:



Structure of the vertical table:


It can be seen that the advantage of horizontal table is that it is intuitive. It is customized according to the current business logic, simple design, and easy to operate. The disadvantage is that when the business logic expands
In most cases, you need to change the table structure. The data in the vertical table is messy, and the field data is redundant.
There are a lot of advantages. It is flexible and can be well adapted when the business system expands. Knowing this, we can implement the product table.
DESIGN: In this design concept, three tables are required, one is the product table, used to store the public attributes of the product, the other is the product classification table, and the last one is
Tables are critical. They are used to store different attributes of different products. They use the vertical table structure,





Note: Through the product expansion Attribute Table, You can dynamically add attributes to a category of products on the page. After adding these attributes, you can use dynamic SQL to submit them.
Generate the corresponding product category attribute horizontal table based on the properties of this product to save the product property value.
The CPU and memory EMS attributes are added to the COMP product. These two attributes are dynamically extracted to generate a horizontal table T_COMP,




How to implement it? With the design idea, the rest is a very dead thing. Maybe this design is not the best, but it is also because I have been searching for some materials for a long time.
Ask someone else to figure out the process ......

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.