arboles
arboles

Reputation: 1331

database structure for letting users place tags on their profile?

I have a users table with the following information

users (id, username, password, email, location, about, sex, age, etc.)

I would like to let users add a maximum of five tags to their profile.

The tags will store their interests. And will be used to suggest users to other users based on similar interests.

Should I create a field, in my users table, where they can store all five tags or should I create a separate tags table with a different row for each tag corresponding to the user_id of who it belongs to?

If I choose option 1, how can I store the tags separated by commas in PHP? I would create variable that stores the tag name, and then how do I add this in the correct format?

Upvotes: 0

Views: 174

Answers (1)

Cassie Smith
Cassie Smith

Reputation: 501

Storying multiple tags in one field could cause problems.

Personally I would make a new table:

tags (id, userid, tag)

As you can see it uses the userid as the foreign key. It will also be easier to count them etc.

Upvotes: 2

Related Questions