Two Right Joins In A Relationship


I am working on some review/rating software and have the table relationships set up as such:


So, an item has multiple reviews from people, and each review has multiple ratings associated with it. How do I add a relationship to get the average rating for an item?

Ratings fk is ‘review’ referencing Review’s pk.

Review’s fk is ‘item’ referencing Item’s pk

Here is what I am playing with in the Item Model

'Ratings'=>array(self::MANY_MANY, 'ReviewReviewRatings',  '3d_review_reviews(review, item)',),

'AverageRating'=>array(self::STAT, 'Ratings', 'reviews(review, item)', 'select'=>'avg("t"."value")'),

but this wouldn’t work because The PK for Ratings it not what is mentioned in Reviews, so is there any way to do this or do I need to do it some other way?