How can I use Gii to create relations between the tables? Should I create them first in my database or they will be generated automatically?
Gii doesn't create a schema for you (like EclipseLink or Hibernate would in Java), it just helps you to create ActiveRecord classes based on the definition of your schema in database and the relationships that it can find between your tables and with the help of some conventions that the framework have. If you want to manage your database changes programmatically you should try Yii migrations. Short answer, you must first create the schema and then use gii to generate active record classes. Hope this helps.