Question

I have this problem in a table where there are 4 columns which include terms describing the product. I want to make this terms editable (and you can add more) in my app and there are 4 groups of them obviously. I created a table who has all these terms altogether but the product table will have to create 4 relationships with the ID of the terms table.

Is this a good solution?

The main reason I don't want to make 4 different tables for the terms is because there aren't many of them and as the app progresses we might have even more different term groups, thus adding many small tables cluttering the database.

Any suggestion?

Update #1: Here is my current schema http://i.imgur.com/q2a1ldk.png

Was it helpful?

Solution 2

You could try a mapping table:

apputamenti(id, ...)

term_map (apputamenti_id, term_id) 

terms (id, text, type) 

So you can add as many terms as you want.

Or if you want to specify the mapping with one more field, change:

term_map (apputamenti_id, term_id, map_type)

so you can use an enum for map_type like enum(tipologia, feedback, target) or whatever your original fields where

OTHER TIPS

Have a product table and a terms (product_id, terms_name, terms_description) which will allow you to add as many or as little terms for each product as you want. You just need to retrieve all terms from the terms table with a particular product id.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top