Active Record Relations

Hello to all the community of Yes It Is framework.

I am new to this great framework and just started my first webapp to play with.

I have three tables:

studentstable:

studentid

studentusername

studentpass

otherinfo

teacherstable:

teachertid

teacherusername

teacherpass

otherinfo

parenttable:

parentid

parentusername

parentpass

otherinfo

I want to make relations between these three tables so a specific teacher can access only his own students, I mean by access only list them, not insert, update or delete, so for the parent only access his own children in the students table, could be one, two or more.

The right to insert, update and delete in the teacher, student and parent tables to be for the admin only.

Thanks for any help

add two foreign keys to the student table. one points to parent table and another points to the teacher table and the generate model using gii this will automatically make the relationship between each other automatically!..

Thank you, will try that.