I have three different users tables, and I would like to know what is the best way to create a private messaging system for them to communicate.
I tried to create it with a simple db scheme:
id (int)
from (int)
to (int)
subject (varchar)
message (text)
timestamp (timestamp)
read (bool)
deleted_to (bool)
deleted_from (bool)
But complications instantly arised because of the three users tables, where user IDs in table A can have ID = 1 and another user in table B can have ID = 2
Any ideas on how to create a better DB scheme? Thanks
use “model” column with varchar type to save which user model the user comes from.
this way you can have several entries with “2” for example. model + user_id then has to be unique.
e.g.: