Consult the database design solution again.

Source: Internet
Author: User
Consult the database design solution again. Consult the database design solution again.

If you want to develop a clothing system on your own and encounter a problem,

That is, a clothing may have multiple colors, multiple sizes (different numbers), different colors (different numbers), different sizes, different colors, and different prices.

I would like to ask you how you can easily add products to the car purchasing function in this situation ??


Reply to discussion (solution)

I think
1. a clothing table requires a default price
2. for clothing of different colors and sizes, the table has a price. the default value is 0.
Check whether there are prices of different sizes and colors when selecting clothes.


1 Clothing table, field: clothing id, clothing name
2 table: size id, clothing id, size
3 Color Table: color id, size id, clothing id, color name
4 Price List: price id, color id, size id, clothing id, price
Of course, this design is estimated to be complicated, but it is simple and clear. you can also design two tables. The first one remains unchanged, and several other tables are combined in a table, however, in this case, the second table will be relatively large, but the search is simple.

Clothing is nothing more:
Brand/origin
Style
Model
Color
Price
Quantity

What is difficult to organize?

1 Clothing table, field: clothing id, clothing name
2 table: size id, clothing id, size
3 Color Table: color id, size id, clothing id, color name
4 Price List: price id, color id, size id, clothing id, price
Of course, this design is estimated to be complicated, but it is simple and clear. you can also design two tables. The first one remains unchanged, and several other tables are combined in a table, however, in this case, the second table will be relatively large, but the search is simple.



This design should be cumbersome and concise.

Clothing is nothing more:
Brand/origin
Style
Model
Color
Price
Quantity

What is difficult to organize?



It is a model with multiple colors and sizes,
For example
The color is red, blue, and green.
Dimensions: 150 160 170

Each color or size has a different price

That is, the above options may be:
Red 150
Red 160
Red 170
Blue 150
.
.
.
.
.

These nine prices.

Clothing is nothing more:
Brand/origin
Style
Model
Color
Price
Quantity

What is difficult to organize?


Is it for style Group?

Ask me for advice.

Color table size table inventory table
Id color id size id name color size num price
1 red 1 150 cm 1 Short Sleeve 2 1 50 78
2 blue 2 160 cm 2 Shorts 1 2 66 88

Join the shopping cart and copy the fields in the inventory table to the shopping cart table.

What is group?

Brand/origin, style, model, color, price
As long as there is a difference, it is a record.

Brand/origin, style, model, color, price
As long as there is a difference, it is a record.



Http://item.taobao.com/item.htm? Spm = a1z10.5. w5003-8066027476.1.WQfhO4 & id = 40200659778 & scene = taobao_shop
Click Connect above

For example, different models and colors may have different prices, but the titles are the same.

In fact, I want to achieve this effect. it may be that my expression is incorrect.

It's just a multi-condition query.
The recommended data structure is suitable for such queries.

It's just a multi-condition query.
The recommended data structure is suitable for such queries.


I thought and thought about it last night. I also found some statements and found that there was no way to implement them. I was confused.

I hope the boss can give me some further instructions. thank you very much.

Clothing table: Brand, style, basic price
Color Table: brand, color, and price increase
Size Table: brand, size, and price increase

Clothes table: Brand, style, color, size, clothes price

Select the clothing brand and display the basic price. select different colors and sizes to increase the price, get the final price, save it to the clothing table or cache it to the session.

How can this problem be solved?
The model, color, price, and inventory quantity of the corresponding products are displayed in the brand/origin/style table.
With this data, is it still difficult to write the interface?

Two tables.
Public information and private information.
For a dress, its name and origin are public information, and its color, size, and price are private information.

How can this problem be solved?
The model, color, price, and inventory quantity of the corresponding products are displayed in the brand/origin/style table.
With this data, is it still difficult to write the interface?



Sometimes it is impossible to steal, maybe it is less than summing up experience, I am really sorry.

I plan to design it like this:

ID product name Product ID model color price inventory quantity
Id Pro_Name Pro_id pro_type pro_color pro_price pro_num
1 children's clothes in summer 0 kids_001 red 95 100
2 1 blue, 98, 100
3 1 purple 92 100
.
.
.
.
.
.

First, add the basic information of a product, and then add more different prices and colors for the product.

Can't you see a table like this? Is there any room for optimization?

ID product name Product ID model color price inventory quantity id Pro_Name Pro_id pro_type pro_color pro_price pro_num1 kids clothes in summer 01 kids_001 red 95 1002 kids clothes in summer 02 kids_001 blue 98 1003 kids clothes in summer 03 kids_001 purple 92 100

For customers and sellers, all products are independent and there is no such item. Only bundled sales are exceptions.

I don't think it is necessary to do it all by the database.

The color and size are basically fixed, which can be all listed.

Generate an xml file, query the file, or read the xml file.

Xmlid matching database

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.