Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tags in mysql + php

Tags:

php

mysql

tags

Is there a common way of dealing with tags in databases?

I'm thinking of using tinytext with pipes. I think adding another table and using IDs might make it more complicated for little gain.

What's your preferred way of doing this?

and what is the right way of doing queries in a table to find results matching multiple or single tags?

Thanks

like image 783
Daniel Avatar asked Nov 20 '25 02:11

Daniel


1 Answers

Implement a simple N:N relations.

Items:
-id
-name
-title
-foo
-bar

ItemTagRelations:
-Fkey itemId
-Fkey tagId

Tags:
-id
-name
-etc

like image 61
erenon Avatar answered Nov 22 '25 16:11

erenon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!