Two views can be tied by a master-detail relationship only if one of the base DataTables, which has the view on which the definition is based, of the master view has a DataRelation defined in the underlying dataset which connects it to some base DataTable of the detail view.
When you specify a parent view for a certain detail view in the Add View dialog box of the C1ViewSetDesignerForm, you can specify this DataRelation explicitly.
If you choose not to specify it, the C1DataViewSet automatically selects some DataRelation which can connect those views. Namely, this DataRelation determines the fields which are used to filter out detail rows for a current master row.
There are cases when more than one DataRelation can connect views, for example, suppose that we have views with the following definitions:
MasterView SELECT * Customers JOIN Orders
DetailView SELECT * Orders JOIN [Order Details]
These views can be tied based on two DataRelation "Customers -> Orders" (Orders from the DetailView here) and "Orders -> Order Details" (Orders from the MasterView here).
In this case it's reasonable to define a base DataRelation explicitly because C1DataViewSet could select a DataRelation other than the one you are supposed to use.
You can specify a parent view in the Add View dialog box when you add a C1DataView. To do this:
You can access the Set Parent View dialog box from the C1ViewSetDesignerForm by clicking the Set Parent View button.
Another complex case when more than one DataRelation connects views is when some or both of the views involved in a master-detail relationship reference the same DataTable more than once (in this case the tables' occurrences in a definition statement are differentiated by their aliases). If the base DataRelation corresponds to such a DataTable, you should have the ability to specify which occurrence of the DataTable must be used (that is, rows of what table alias participate in the relationship). You can do this by explicitly defining an involved DataTable alias in the Set Parent View dialog box. To do this: