I am creating a system in which I am planning to let User A generate a special chat link so he/she can communicate with User B. This is a 1-1 chat model. The schema of my model is below. I need to know if its practical or if it can be improved.
table messages
chatid; {fk}
message_id; {pk}
timestamp;
sender;
table chat
chatid; {pk}
userA;
userB;
timestamp;
Here is the control flow of the scenario:
- User A has intentions to chat with User B.
- User A goes into the generate chat session page.
- User A selects the User B from the list.
- User A generates the chat session /app/chatid/007
- User A copies and pastes the URL to sent it to User B via the inbox.
- User A and User B agree on a time they wish to chat
I know, a bit weird, because I dont know how to implement a system where user is checked for online/offline, although you could pop in if you have ideas.
- User A opens the chat URL on hh;mm and so does User B.
- They start chatting.
- The page doesn't reload and they chat with fun.
The end. Waiting for your responses.
Editted by Asker
I was looking at this schema. I don't know how I would further add to it to show user a/user b being online/offline; perhaps last_activity? You tell.
tbl_chat
-------------
chat_id (pk)
user_id_a (fk)
user_id_b (fk)
timestamp
tinyint;
tbl_msg
-------------
message_id (pk)
chat_id (fk)
user_id_sender (fk)
message_body
timestamp
added tinyint; to tbl_chat so when user A clicks kill chat, it makes it 1 , default of tinyint =0; So that kills chat.