Data table design problem

now there are data tables as follows
data classification table
cate_id
cate_name
pid

Commodity list

goods_id
goods_name
cate_id

property sheet
attr_id
attr_name
goods_id

the requirements are as follows. Originally, attributes can be found indirectly through commodity table classification, but now the classification table needs to directly associate attributes and classify a pair of multiple attributes. How to design the data table data will not be redundant

Jan.08,2022

how about this design?
disassociate the commodity table from the property sheet

create a new intermediate table
attr_id
attr_type [1 is category 2, commodity]
connect_id decides whether to associate goods_id or cate_id according to attr_type


this feeling still needs to design the table structure according to the actual requirements.
what is the relationship between property sheets and classifications. Model relationships, such as one-to-one, one-to-many, many-to-many relationships.
then you can design a reasonable data table.


@ chinasky has a good solution.

tell me what I understand:

how many attributes does a commodity have?

if there is only one attribute, delete the property sheet directly and add the property field to the item table.

if there are multiple attributes. Then there is redundancy. Because classification is also associated with attributes, goods are also associated with attributes. Then the goods_id of the property sheet is useless. It has to be deleted. Then add an intermediate table, which I think is easy to understand and data separation. Build 2 intermediate tables. Classify and attribute, create an intermediate table. Goods and attributes, create an intermediate table.

Is there an one-to-one relationship between the

property sheet and the commodity table? A commodity corresponds to an attribute?
if so, the direct commodity table and the property table are merged.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e42301-4c09d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e42301-4c09d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?