简体   繁体   中英

MySQL three tables, one table contain linked values of two other tables

I write php aplication with mysql support. Idea is based on form fields containing characteristics, that can be added and deleted from website template. Through form fields i insert values of created characteristics, and can be of all types: checkboxes, radio groups, selects, text ...etc, and some selects can be chained. That explanation was just for getting wider picture.

My database design contain three tables:

FIRST containing items content - products;

SECOND containing values of characteristics - charact_values;

THIRD must contain id's of first and second table, per row, that linking that two table values.

So then I now values ​​that belong to each product.

I don't want duplicate values, i only want link them in third table. I don't now how many characteristics user will add to product and with that shema it is possible.

My fear is what will happen when user put 5 000 products and each product will have about 100 characteristics, that will be about 500 000 rows in third table.

Is it to much for third table? Maybe exist some other database design I can use for that funcionality. I can't figure out another shema that will not produce some huge amount of rows in some table.

Your schema is the correct and normalized way of implementing your scenario in my opinion. And even though the third table may run into tens of thousands of records, you are not going to query them all at once.

Example. You might display the products list, then only upon selecting the product, you will be querying the characteristics. So despite the large database, I dont think it will cause any problems.

Go ahead with this schema itself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM