I'm working on a blog system (cliche I know, but it's a class assignment), and I want to be able to attach tags to my posts. I have a tags table and a posts table and their fields look like this:
| p_id | c_id | u_id | title | body | published |
--------------------------------------------------------------------------
| 1 | 1 | 1 | first post |lorem ipsum |2012-01-27 18:37:47|
| t_id | name | slug |
-----------------------------------
| 1 |programming | programming |
At first I thought I could just add a new field in the posts table and have a foreign key reference to each tag, and that would work if there was one tag per post, but how do I reference more than one tag?
The only thing I can think of is have another table called post_tags
or something, and then reference them through that table. Is there a better way? Thanks.