Flying_Banana
Flying_Banana

Reputation: 2910

How to store a set of values from another table in a field in MySQL

I'm running on a version of MySQL that does not support foreign key relationships.

Suppose I have two tables, one holds a number of users while the other one holds a number of topics. I want each of the topics to have a field which holds a set of user id's who participated in that topic. I read the type SET's documentation and it says it must be values from predefined values. So how should I go about doing this?

Upvotes: 0

Views: 50

Answers (1)

rjdown
rjdown

Reputation: 9227

You don't want an extra field, this is a very inefficient way of storing such things. You want a new table.

In your third table (called, say, topicUsers). you would have just two fields: userId and topicId. Then you can look at this table and join data from the others as needed.

This is called normalisation

Upvotes: 1

Related Questions