ObjectExtender User's Guide and Reference

Creating a secondary table map

A secondary table map is necessary when a persistent model class is mapped to two or more database tables. An example of this type of mapping can be found in the Bank sample model.

Launch the Map Browser, and select BankSample from the Datastore Maps view, and then select VapCustomer from the Persistent Classes view.

Note that two table maps are present for the VapCustomer persistent class. The CUSTDATA is the secondary table map.

It was created as follows

  1. In the Bank sample schema, there needs to be a CUSTDATA and CUSTOMER table with all of the necessary columns added. It is the CUSTDATA table that is going to hold additional information for the VapCustomer persistent class.
  2. Create a foreign key relationship named custdata-customer where CUSTOMER is the primary key table and CUSTDATA is the foreign key table. (Recall this is done using the Schema Browser).
  3. In the Map Browser, select VapCustomer.
  4. Create the CUSTOMER table map with no inheritance.

    Note that when mapping the attributes in the Property Map Editor for this table, the birthDate, felon, rating, and sex will not get mapped because this table does not have the fields necessary to map these attributes. All of the associations can be mapped from this table.


    Figure pgs2k not displayed.

  5. From the Table_Maps menu, select New Table Map - Add Secondary Table Map.
  6. Select the CUSTDATA table from the Table menu.
  7. Select the custdata-customer relationship from the Foreign Key Relationship list.
  8. Select OK.
  9. Select the CUSTDATA table map.
  10. Select Edit Property Maps from the Table Maps menu.
  11. Select the corresponding table column for the class attributes: birthDate, felon, rating, and sex.
  12. Select OK.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]