Friday, May 30, 2014

User table foreign key confusion

Hi,
I am confused about how the User table is linked to other tables.
To keep things simple I have a working version of a linked cakephp/mysql that can display ,add,edit records.

I add in security with a admin role who can see every page.
Everything is OK but I will need to add users with access to only somethings.

I have these tables

teachers
student
teacher-student (tutor sessions)
User

The question how do I link the User to the students,techers table as the user table seems to be a special case?
Would I need a user_id in these 2 tables and the user has foreign keys of teacher_id and student_id?
What about admin roles who can see all pages as they dont need a teacher or student id?
Or dont I bother linking tables as User table is a special case?

Do I need to set up a teachers table with id and also a user_id which is the same thing?

In cakephp  I link like this for example.

class User extends AppModel {
   
     public $hasOne = array('Teacher','Student');
  


class Teacher extends AppModel
{
   
    public $hasOne = 'User';


--
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: