Delete In Tables With Relationship Yii And Mysql?

I have 3 tables : User—HAS::MANY—>Skill—HAS::MANY—>Job. I want to delete User and it will automatically delete all SKills of this user and all Jobs belong to these skills. With Yii, we have to put some code in the UserController::actionDelete() ,that find all the Skill related to User then delete all of them or the relationship that we declare in the both models will do the rest?

And about the relationship HAS:ONE. If I have:


A--HAS::ONE-->B;

B-->BELONG::TO--->A;

C-->HAS::ONE-->B;

B-->BELONG::TO--->C;

Could it happens if I delete one of them, other will be the same?

I think you should make this activity using mysql directly (reference).

Use InnoDB as your database engine and add an ON DELETE CASCADE constraint to the foreign key. No PHP code required.