mysql - Extend database for group/collaborative messaging -
i have following database schema messaging app i'm creating:-
table name:- conversation_threads
+-----------------+-------+---------+ | conversation_id | label | members | +-----------------+-------+---------+ | 1 | test | 1,2 | +-----------------+-------+---------+ | 2 | xyz | 4,1 | +-----------------+-------+---------+
table name:- messages
+------------+----------------+-----------+-----------------+---------------------+ | message_id | message | sender_id | conversation_id | created_at | +------------+----------------+-----------+-----------------+---------------------+ | 1 | hello | 1 | 1 | 2017-09-12 09:00:00 | +------------+----------------+-----------+-----------------+---------------------+ | 2 | hi | 2 | 1 | 2017-09-12 09:02:00 | +------------+----------------+-----------+-----------------+---------------------+ | 3 | hey! | 4 | 2 | 2017-09-12 08:16:00 | +------------+----------------+-----------+-----------------+---------------------+
table name:- message_users
+----------+-------------+---------+--------+ | mu_id | message_id | user_id | status | +----------+-------------+---------+--------+ | 1 | 1 | 1 | read | +----------+-------------+---------+--------+ | 2 | 1 | 2 | unread | +----------+-------------+---------+--------+ | 3 | 2 | 2 | read | +----------+-------------+---------+--------+ | 4 | 2 | 1 | unread | +----------+-------------+---------+--------+ | 5 | 3 | 4 | read | +----------+-------------+---------+--------+ | 6 | 3 | 1 | unread | +----------+-------------+---------+--------+
this schema works quite fine one-to-one messaging.
but want introduce more 2 users in single conversation 3 or 4 or more people can collaborate , discuss things.
what facing problem if add user in members
field in conversation threads - gets accessibility read messages present in particular conversation thread since beginning - although added late conversation.
please provide me solution on how tackle particular problem.
hope question not broad.
if understand schema relation have put members did
+-----------------+-------+---------+ | conversation_id | label | members | +-----------------+-------+---------+ | 1 | test | 1,2,3,4 | +-----------------+-------+---------+
Comments
Post a Comment