Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

elbojoloco's avatar

Storing chat messages in database for multiple purposes

Hello,

I have a chat system that works fine, but I want to expand the chat system to serve multiple occasions instead of just 1.

For example: I have a chat in a match (a 1v1 match) and the messages in that chat have a "match_id" column to easily access them from the match model. But now I want to use messages for direct messaging aswell, however, I don't want to assign a relationship for each and every purpose, there will be more.

How could I store the messages in such a way that they are easy to assign to seperate chat systems, (match chat, direct message, public chatroom, etc..) and also easily access them.

0 likes
0 replies

Please or to participate in this conversation.