Monday, June 2, 2014

Re: User table foreign key confusion

Ok, if your model(s) work, what actually is your question?

1. Have you defined your tables in the database with foreign keys? For example like this:
Users table
id = primary key
name = full name of user
username = Username, unique identifier of the user
...

Teachers table
id = primary key
user_id = foreign key to Users table
...

Students table
id = primary key
user_id = foreign key to Users table
...

2. If the above does not reflect what you have, please show us what you have.

Enjoy, John

On Monday, 2 June 2014 02:23:55 UTC+3, jagguy wrote:


I already know what you are talking about and have already set up the database as you have shown before you posted.
but my question was about setting up a foreign key in the Users table.
 
I have  the relationships set up in User/Teacher but do I have a foreign key in each or just leave 1 table to have the foreign key.
This is a cakephp question as normally I would just have the User having no foreign key and the Teacher having the foreign key so just 1 table has the link.

Currently my model works .
[snip]

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: