B
B
brainflow2016-12-09 12:45:32
PostgreSQL
brainflow, 2016-12-09 12:45:32

What database schema to choose for hashtags in total?

There is a social network, there is different content: posts on the wall, comments, videos (with descriptions), photos, messages.
For all content types, the user can write a #hashtag.
When you enter #hashtag in the search, there should be a search for all types of content.
Tell me, please, how best to organize this at the database level (we use postgresql).
As the most obvious solution:

  • table with content
  • Table with tags
  • Table linking tags with content tag_id -> content_id
  • On the frontend or backend, convert the #hashtag into a link

What I don’t like is that when adding a post in which there will be 50 tags, you will have to make 50 requests to search for tags in the tag table, then 50 inserts into the link table, ideally update the counters, but this can be removed in the background.
Can you suggest a better solution.
Just googled this on SOF:
stackoverflow.com/questions/9282091/best-way-to-ma...
stackoverflow.com/questions/48475/database-design-...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mistergonza, 2016-12-09
@mistergonza

Of course, I'm not a specialist in Postgres, as an option, you can use a json type field in a table with content for tags.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question