Good day to all! The task is to make a chat correspondence, users can communicate with each other both on the product page and in the personal account. There will be many users and many messages.

It is necessary to make 2 tables in mysql - "Chats" and "Messages".

Question: What is the best way to do these two tables? What is it to keep so that it is competent and does not slow down the functionality?

    1 answer 1

    You can make a chat table:

     chat_id(INT), author_id(INT), recipient_id(INT), product_id(INT) 

    chat_message table:

     message_id(INT), chat_id(INT), author_message_id(INT), message(TEXT), date_added(DATETIME), status(INT)