fetch multiple rows from related tables and display as form

Hi all,

I have 3 tables

survey ->sid (primary key),name

questions->qid(primary key),question and sid( (foreign key from survey table)

answer table -> aid (primary key), answer, qid (foreign key from question table)

I want to fetch and display all the questions and answers where sid=1 and display them as a form so that user can enter the answers. And i want to store the user entered ans with the answer column in the another table.

How can i do that in Yii?



Please start with relational active record description.