Clothing Database Schema Design

I am working on inventory management for a clothing store, but I stuck with a clothing model.

Must have a Style class,

public class Style{
   String styleNumber;
   String[] colors;
   String[] sizes;
   int quantity;

}

As well as the item of clothing:

public class Garment{
       Style style;
       String color;
       String size;
       int quantity;

    }

For example, one style has two colors, and each color can have four sizes, so clothes can have 2 * 4. We need to request an inventory of a certain color or size.

Could you guys give me some tips on the database schema schema? Thank.

+3
source share
2 answers

This is what you need, I suspect.

TABLE: Colour

ID    Colour
1     Green
2     Red

TABLE: Size

ID    Size
1     Small
2     Medium

TABLE: Garment
ID    ID_COLOUR  ID_SIZE  INVENTORY
1     1          1        3
1     1          2        1

With this approach, you can choose whether you save lines with inventory 0 or not.

, kdistinct, , GARMENT.

, :

TABLE: Colour

ID    Colour
1     Green
2     Red

TABLE: Size

ID    Size
1     Small
2     Medium

TABLE: Style
ID   ID_COLOUR ID_SIZE
1    1         1
2    1         2

TABLE: Garment
ID   ID_STYLE  INVENTORY
1    1         10
2    2         3

. , .

+1

:

  • , Style.styleNumber
  • , Garment.style /
  • Garment (auto_increment)
  • colors, sizes Garment Style
0

Source: https://habr.com/ru/post/1730945/


All Articles