Where To Build Relations? Mysql Or Active Record [Solved]

I got the book “Agile Web Application Development with Yii 1.1 and PHP5”. I am working through it, and have gotten sidetracked on a small personal project. I am just starting out, and wondered if anyone could tell me if I should create foreign keys in MySQL, or handle that in Yii with Active Records, or both? I just don’t know enough about this to even ask the right questions.


create relationship between tables directly using any client like phpmyadmin and then generate the models through gii. it will automatically build relationship b/w models in activerecord :)

Thanks for the quick reply, I have just installed phpmyadmin, and will setup the tables how I would like them to be. It just seems to easy to have Yii do the rest.

write some queries on phpmyadmin or use yii migrations to do the same.


You must create the relationships both MySQL and Yii.

Fisrt, you must create the relationships in MySQL.

And then, you can use Gii to create the relationships in Yii (or make them by hand).