Say I have a simple database with the 'posts' and 'tags' tables. Messages can have many tags and tags that can belong to many messages.
What is the best way to structure a database? I was thinking about using list / serialization:
tags
idx tag_id, str tag_name
posts
idx post_id, str title, list tag_ids
OR have another table with associations. The problem is that I don’t even know how to structure the request in order to pull the associated tag names when I receive the message.
posts
idx post_id, str title
post_tags
fk post_id, fk tag_id
Actually, I don't like any of them. Is there a better way?
source
share