D
D
Dmitry Volkhontsev2017-05-11 08:15:21
PostgreSQL
Dmitry Volkhontsev, 2017-05-11 08:15:21

What is the best way to compare tables?

Good day.
I am new to PostgreSQL and I have the following question:
There are two tables users and groups. Accordingly, users can enter groups. And here the question is, in what way is it better to compare the data of the table with each other?
Option 1 - create a separate table users_in_group Option
2 - create an Array type field in the group table, and add users there.
Please tell me, is it worth considering the second option, and what is their fundamental difference?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
shushpanio, 2017-05-11
@DarkDD

Can a user be in multiple groups at the same time?
If so, make a table like:
User_ID||Group_ID
If a user can only belong to the 1st group, then simply add the Group_ID column to the USERS table and write down the ID of the group to which the user belongs.

L
lega, 2017-05-12
@lega

There is another option: a list of groups that is stored in each user.
Tspolzuyte the option that will give the necessary minimum effort (cost), for your specific task.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question