W
W
WAYNEDEV2021-07-30 21:05:08
PostgreSQL
WAYNEDEV, 2021-07-30 21:05:08

How to store user categories in postgres?

There is a table of categories and users, you need to make a way to bind several categories to a user.
How can this be implemented, so that later you can search by user depending on the filter by category?

I can't think of a better option and there are no answers on Google.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
galaxy, 2021-07-30
@WAYNEDEV

Standard many-to-many relationship via link table

users
__________
id
name
...

categories
__________
id
name
...

user_categories
__________
user_id
category_id

Basically, if the categories are just text tags, you can store them in a field of the users table as JSON, for example.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question