Consult the database design again.

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

Want to develop a clothing system yourself, encounter a problem,

is a garment may have more than one color, there are a variety of sizes (number of different), a variety of colors (the number of different), different sizes and colors are different prices, I le a go.

Want to ask the heroes, you encounter this situation, how to dial, but also to facilitate the product to buy car function??


Reply to discussion (solution)

I think
1, the clothing table to a default price
2, different colors and different sizes of clothing corresponding table a price, the default is 0
When choosing clothing, check whether there are different sizes of different color prices


1 Clothing table, field: Costume ID, costume name
2 dimension table: Dimension ID, costume ID, size
3 Color table: Color ID, dimension ID, costume ID, color name
4 Price list: Price ID, color ID, size ID, costume ID, price how much
Of course, this design will be more complex, but simple and clear, you can also design 2 tables, the first one unchanged, the other several pinch up in a table, but then the second table will be larger, but the search is simple.

Clothes are:
Brand/Origin
Style
Model
Color
Price
Number

What's so hard to organize?

1 Clothing table, field: Costume ID, costume name
2 dimension table: Dimension ID, costume ID, size
3 Color table: Color ID, dimension ID, costume ID, color name
4 Price list: Price ID, color ID, size ID, costume ID, price how much
Of course, this design will be more complex, but simple and clear, you can also design 2 tables, the first one unchanged, the other several pinch up in a table, but then the second table will be larger, but the search is simple.



This design should be cumbersome and not concise.

Clothes are:
Brand/Origin
Style
Model
Color
Price
Number

What's so hard to organize?



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

Each color or size has a different price

The choice above may be
Red 150cm
Red 160cm
Red 170cm
Blue 150cm
.
.
.
.
.

Such 9 kinds of prices.

Clothes are:
Brand/Origin
Style
Model
Color
Price
Number

What's so hard to organize?


Is it the style Group by?

Ask big old again pointing pointing.

Color Table Size Table Inventory table
ID color ID Size ID name color size num Price
1 Red 1 150cm 1 short sleeves 2 1 50 78
2 Blue 2 160cm 2 Shorts 1 2 66 88

Add a shopping cart and copy the fields from the inventory table to the shopping cart table.

The customer is the specific clothing, group is what?

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

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



Http://item.taobao.com/item.htm?spm=a1z10.5.w5003-8066027476.1.WQfhO4&id=40200659778&scene=taobao_shop
Click on the link above

Like this, choose a different paragraph, different colors, may be different prices, but its title is the same AH.

In fact, I just want to achieve this effect, may be I express wrong.

It's just a multi-conditional query.
I suggest that the data structure fits the query exactly

It's just a multi-conditional query.
I suggest that the data structure fits the query exactly


Last night to think and think, also found some statements, found that there is no way to achieve, really can't touch the mind

Also hope that the eldest brother detailed guidance, thank you very much.

Clothing table: brand, style, basic price
Color table: brand, color, price increase
Dimension table: brand, size, price increase

Clothes table: brand, style, color, size, clothing price

The user chooses the clothing brand, displays the basic price, chooses the different color and the size to increase the price, obtains the final price, saves to the clothes table or caches to the session

Why is it so not enlightened?
The model, color, price and stock quantity of the corresponding product will be obtained with the brand/origin and style check list.
With this data, is it difficult to write the interface?

Two tables.
A piece of public information, a piece of private information.
For a garment, its name, origin, etc. are public information, and its color, size and price are private information.

Why is it so not enlightened?
The model, color, price and stock quantity of the corresponding product will be obtained with the brand/origin and style check list.
With this data, is it difficult to write the interface?



Sometimes it is not possible to open a burglary, may be less than the experience of their own summary, really embarrassed.

I'm going to design 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 Kids Summer 0 kids_001 Red 95 100
2 1 Blue 98 100
3 1 Purple 92 100
.
.
.
.
.
.

First add a product basic information, and then continue to add a number of different prices, colors and so on the product.

Do you think such a table is OK? Is there 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      small children's wear summer          kids_001     Red           1002      small children's wear summer          kids_001     Blue           98           1003      small children's wear summer          kids_001     Purple           100

For the customer and the merchant, all the goods are independent, there is no one. There's only one exception to the bundled sale.

I don't think it's necessary to complete the database entirely.

Color, size, these are basically fixed, and then some, these can all be enumerated.

Generate an XML, query, or whatever, read the XML

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.