Say For Example, One Author has many Books.So we can write this in form of $hasMany association as below,
var $name = 'Author';
var $hasMany = array('Book' =>
array('className' => 'Book',
'conditions' => '',
'foreignKey' => 'author_id',
'dependent' => true,
'exclusive' => true
)
);
dependent: When dependent is set to true, recursive model deletion is possible. In this example, Book records will be deleted when their associated Author record has been deleted.
exclusive – If set to true, all the associated objects are deleted in one SQL statement without having their beforeDelete callback run.This greatly improves performance, but may not be ideal for all circumstances.
Now just look at the records in the database
authors table
===================
id name
===================
1 first author
2 second author
3 third author
books table
==================================
id title isbn author_id
==================================
1 abc 6416446846 1
2 xyz 3146354313 1
3 pqr 8945468485 2
4 fgh 6434164656 2
5 rtt 1215445644 3
Now if you delete any record of Author,all the associated books with that particular Author will also be deleted.