Which of the two ways should I use to insert tags into mysql?

Posted by ggfan on Stack Overflow See other posts from Stack Overflow or by ggfan
Published on 2010-05-14T03:27:44Z Indexed on 2010/05/14 3:34 UTC
Read the original article Hit count: 191

Filed under:
|
|

For each ad, I allow users to choose up to 5 tags. Right now, in my database, I have it like...

Posting_id     TagID
    5            1
    5            2 
    5            3
    6            5
    6            1

But i was thinking if I should make it like...

    Posting_id     TagID
    5              1 2 3 
    6              5 1

Then first option is much easier to insert and retrieve data. But if I have 100 posts with 3 tags each, that's 300 rows...so ALOT more rows

The second option requires using explode() impode(), etc but it is much cleaner.

Which option should I do and why? thanks!

© Stack Overflow or respective owner

Related posts about tags

Related posts about php