1 year ago

Chat's database structure

Posted 1 year ago by Cinek

Hello, I have one problem with designing database structure for my app. I have 3 models: Events, groups and users. Relations: Events - Users - many to many Groups - Users - many to many

There will be available one chat withing group and one inside event. Additonally in the near future I am going to implement chats between two or more users.

i'm a bit confused what is the best way to design it. I created Chat model and many to many relation between chat and users.

1 idea: The members of group and event chats will be stored in respectively event_users and group_users tables. Only chats between users will be stored in chat_users.

Second idea: chat_users will be synchronized with event_users and group_users tables. The advantage of this way is that I will have simple separated logic to manage chats and there will be not many complicated queries to DB.

Thanks for any feedback or maybe other ideas

Please sign in or create an account to participate in this conversation.