select * from rating_dimensions $extra_query select * from rating_dimensions where dimension_key = :dimension_key select dimension_key, title from rating_dimensions select rating_id, rating from ratings where object_id = :object_id $extra_query select avg(rating::float) from ratings where object_id = :object_id $extra_query select rating from ratings where object_id = :object_id and owner_id = :owner_id and dimension_id = ( select dimension_id from rating_dimensions where dimension_key = :dimension_key )