Just a few days ago, I found out about this miracle called CakePHP , so I'm pretty green. I need to create a mail application, so I executed the agreement and created:
Database Description:
User table <user_id (primary key), fname, lname>.
The table of mail messages <mail_id (primary key), from (foreign key to user_id), to (foreign key for user_id), contents, open>.
My questions:
1) According to the agreement, the foreign key should be called a linked table + '_ id'. How can I call columns if there are two foreign keys that belong to the same table. Both from the table and from it.
2) I would like to make an internal JOIN between two tables. Sort of:
SELECT user_id, mail_id
FROM users
INNER JOIN mails
ON users.user_id =mails.to AND mails.opened=false.
, .