How to design schema and database for tagging system?

Hi!
I need your help! I am trying to understand tagging system(like post has tags). But I don’t understand very well.
For example, User can have multiple self descriptive tags like, housewife, influencer, actor, Tv hosts etc…
I think what I want to do is same as this forum does for tagging.

  1. Suggesting already created tag and if it doesn’t exist, create one.
  2. When click the tag in this forum’s post, shows post that has same tag(get posts by tag that I clicked)

My thought is just using has_many/belongs_to association.
Is this correct? and what is the best practice for implementing this tagging?

You can find a tagging system example with Ecto upserts here…

https://hexdocs.pm/ecto/constraints-and-upserts.html

2 Likes