I have multiple tables that are related by primary key-foreign key relationship. Also, I have models that are independent of each other on top of these tables. Now, I need a view that displays the data from multiple tables. How should I do this? Should I create a dummy model with attributes from each of the table? If so, how and where do I perform the query to these multiple tables. Any code snippets will be of great help.
To be more clear, here is an example. Assume these are the following tables.
Table1: pk, attr1, attr2, attr3, attr4, attr_fk_table2, attr_fk_table3, attr_fk_table4
Table2: pk, attr1, attr2, attr3, attr4,attr5
Table3: pk, attr1, attr2, attr3
Table4: pk, attr1, attr2, attr3
Also the models of tables 1,2,3,4 are independent. I mean to say there is no has_one or belongs_to relation between them at the model level.
Now I need a view with the following attributes
Table1:attr1, Table1:attr2, Table2:attr5, Table3:attr3, Table4: attr2
How can I do this?
Thanks