Skip to main content

Master-Detail Tutorial. Step 4: Setting Up Master-Detail Relationships

  • 2 minutes to read

Two master-detail relationships must be set up. The first one is between the master FILMS and detail STAFF tables. The second one is between the master FILMS and detail FILMSSCREENS tables.

  1. For the first relationship, you need to adjust the properties of the tvStaff View. Open the Object Inspector and set the attributes as follows:

DetailKeyFieldNames specifies the field(s) from the detail tvStaff View. The MasterkeyFieldNames property specifies the field(s) from the master tvFilms View. Detail key fields must correspond to master key fields. The KeyFieldNames property specifies the field(s) in the detail View uniquely identifying each record. Refer to its description for more information.

  1. For the second relationship, set the properties of the cvFilmScreens View as described for the tvStaff View:
  1. The datasets displayed in detail Views must be sorted against fields addressed by the DataController.DetailKeyFieldNames property. This is necessary for the detail data controller to be able to correctly retrieve all the necessary records from it. To sort data in the tblStaff and tblFilmScreens tables, set their IndexFieldNames properties to FILMID.

All the properties affecting master-detail relationships have been set and you can now run the program. The following steps refine the application by specifying editors for particular columns/card rows, customizing the View’s layouts, and by improving the appearance of the grid.

See Also