79623593

Date: 2025-05-15 14:38:08
Score: 1
Natty:
Report link

If your chat is between 2 users only and it won't change, chat table is extra. You can keep you message as:

ID (long) IdSender (INT) (FK) IdReceiver (INT) (FK) Message (TEXT)

But make some indexes. You've made absolutely normal and universal structure for small database. Even if you have 3, 100 or 1 user in chat, you always need to keep link to sender and to chat.

But better... Don't keep messages in database. You can save posts, comments, but not every single message. Even if you make goos bw-trees indexes, it will become laggy. Use special services for this (for example, special files or storages)

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: tankoman 228