Reputation: 1327
I have two tables : products and tags.
key | name | description | url
key2 | tag | tag description
eg a product "plate" has the tags "ceramic", "white", "delicate", etc associated with it.
I don't know however how to create a many-to-many representation.
What's the best way to store these tag associations? Create a tags field in products? Or another table? Thanks!
Edit: tags are many-to-many, thanks S.Lott
Upvotes: 1
Views: 142
Reputation: 391854
One tag can be associated with many products and each product has one or more tags associated with it.
That's not a one-to-many. That's many-to-many.
Google "Association Table" or "Junction Table" for numerous examples.
http://en.wikipedia.org/wiki/Junction_table
http://www.youtube.com/watch?v=P_nhBKs25DQ
Upvotes: 3
Reputation: 11590
I would go with an additional table named (productTags: key, productKey, tagKey) that would map the two tables together.
Upvotes: 1