I just begin to learn PHP and CackePHP 3.
I try to design DB.
I would like to realize messages table.
Users can post messages each other.
I have users table.
As I see it should be many-to-many relaction.
In messages table I need 2 fields with user_id. The first user_from_id, the second user_to_id.
But there are Name Conventions in Cake.
How should I realize comments table in view of Name Conventions? How should I name the first user_id field and the second one?
Am I right when I think that I need this fields?
CREATE TABLE messages (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
userto_id INT NOT NULL,
message TEXT NOT NULL,
FOREIGN KEY user_key (user_id) REFERENCES users(id),
FOREIGN KEY user_key (userto_id) REFERENCES users(id)
);
Am I right? And how it will be better realize in model and controller?
Thank you for your wish to help.