I have a table named size here, something like this:
size id | size name
1 S
2 M
3 L
4 XL
But I am confused when I found that the size must have any category, I mean something like cloth_size, pant_size, sheets_size. That would be different. Row will be 6XL, 5XL, 4XL. I think I should crate the table sheets_size like:
size id size name
1 S
2 M
3 L
4 XL
5 XXL
or should I create the table category like:
category_id category_name
1 cloth
2 dress
3 pants
4 sheets
table size:
size id | size name | category
1 S 1
2 M 1
3 L 1
4 XL 1
5 XXL 4
Which one better?
I believe the best and easiest method is to have a table with all categories, like you described:
and then have a table with all sizes (from S to 6XL)
These two tables will be in a many-to-many relationship since one category can have many sizes and one size can belong to many categories. This means that you will need a third table to hold the primary keys of each table.
This basically translates to category 1, has sizes 1 and 2, as in cloth has sizes S and M.