How to implement tag system

后端 未结 7 1688
悲&欢浪女
悲&欢浪女 2020-11-28 00:19

I was wondering what the best way is to implement a tag system, like the one used on SO. I was thinking of this but I can\'t come up with a good scalable solution.

I

7条回答
  •  旧时难觅i
    2020-11-28 00:49

    If your database supports indexable arrays (like PostgreSQL, for example), I would recommend an entirely denormalized solution - store tags as an array of strings on the same table. If not, a secondary table mapping objects to tags is the best solution. If you need to store extra information against tags, you can use a separate tags table, but there's no point in introducing a second join for every tag lookup.

提交回复
热议问题