Answer the question
In order to leave comments, you need to log in
How to implement database structure?
Good time. I'm writing a chat. Faced the problem of implementing rooms in the chat.
Now such structure db:
And a problem such. Can't figure out how to link two users to the chats table? So that, for example, when logging into your account, the user sees his rooms.
I hope you understood what I meant.
Answer the question
In order to leave comments, you need to log in
This is called a many-to-many ratio.
It is set by a separate plate of the form
CREATE TABLE `xref_user_chat` (
`user_id` int(11) NOT NULL,
`chat_id` int(11) NOT NULL,
PRIMARY KEY (`user_id`,`chat_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question