Answer the question
In order to leave comments, you need to log in
How to design a database for dialogs?
The dialogue has from 2 users (4, 5, 10 people, etc.).
Before, I wrote the dialog in "users" people separated by commas, i.e.:
dialog_id | users
1 | 2,3,4,5
And when displaying his dialogs, he used the following construction:
WHERE users LIKE '{$user_id},%' OR users LIKE '%,{$user_id}' OR users LIKE '%,{$user_id},%'
Answer the question
In order to leave comments, you need to log in
Are there more "beautiful" methods of communication between the dialog and the user?
Option to create another table dilog_users
dialog_id | user_id
1 | 2
1 | 3
1 | 4
1 | 5
But it seems to me that this will not really inflate the database, and there will not be much difference.
LIKE is a wildly slow operation, it should be used in extremely rare cases, and then only for small tables.
Your MANY_TO_MANY option below is orders of magnitude better.
Go PostgreSQL
https://www.postgresql.org/docs/9.1/static/arrays.html
blog.lerner.co.il/looking-postgresql-arrays
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question