I am developing a piece of software which is designed to track customer complaints, and looking at QT as an option for a framework. It uses SQL as a database backend.

Background: The product is designed to track complaints for products. There is a table for a list of products, an another for batches, which has a foreign key to products (ie, one batch relates to one product).

I have been able to use QSqlRelationalTableModel for some functionality (ie, adding users which have foreign keys to department tables, sites and adding products) and this seems to work well for these simpler sections, where it is a table of data with foreign keys to other tables, where I only need to use one column of data for a combobox.

Now, the complaints involve multiple tables. One main table for the complaint, which has a foreign key to a batch (which then links to product by another foreign key). Note that batch isn't mandatory, in some cases it will be NULL. There is an investigation table, separate, which stores results of the investigation, and the complaint table has a foreign key to that.

I also want the option to line multiple investigations to a complaint, in which case, there will be potentially a many to many relationship between investigations and complaints, which may be required.

My question is, is QSqlRelationalTableModel up to the task? Most of the time, work will be done on one 'row' at a time, but I would like to keep the program performant. Does using QSqlRelationalTablelModel make sense if you only are seeing one row of data? If it loads the entire table, thats unnecessary, and I may be better of subclassing QAbstractTableModel or ItemModel and doing my own? (the number of complaints is most likely to be a two or three digit number). Also, the widgets do match up with the database rows, more or less.

All the examples I've seen online regarding the SQL table models, involve setting up relations with one table, but what if table A has a foreign key to table B, which has one to table C, and you need to display information from table C as well as B in the form? Can QSqlRelation do this and allow the necessary widget mapping? Also, if the data is worked on one row at a time (via a form with widgets mapped), do these models cause unnecessary overhead by loading the entire table, or can you limit it to loading select rows? Or does this not matter?

If these classes aren't up to it, I'll have to subclass the AbtractModel, but I would like to avoid that if possible.