1

Lets say one wants to create a DB to store items, each having a Set<String> tags, associated with it. A straightforward way would be a flat table with ItemID, ItemName, DateCreated,... and a Set<String> tags. This is going to be inefficient for requests

Select * from MyTable where tags like '%my_tag%'

What is the efficient way to store these tags? Should I create a single (huge) table with a compound key ItemID || tag_number || tag, or should I create a lot of small tables, each storing tags for a given item?

Will the answer change if I use PostrgeSQL?

2
  • 2
    databasesoup.com/2015/01/tag-all-things.html
    – user1822
    Commented Apr 21, 2017 at 20:29
  • What is tags like '%my_tag%' supposed to mean? Are you trying to look for a partial match on any tag, or are you searching for a complete tag within some kind of delimited string?
    – jjanes
    Commented Apr 24, 2017 at 16:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.