When you map a database schema to CMP beans, most beans map directly to tables, and the bean fields map to columns of the table. A primary table is the table that most closely matches the bean you are mapping.
Once a bean is mapped to a primary table, you have the option of mapping one or more secondary tables. A secondary table enables you to map columns that are not part of your primary table directly to fields in your bean. You might want to do this if, for example, the data that represents a logical object is split across two or more tables.
A secondary table must be related to the primary table by one or more columns whose associated rows have the same values in both tables. This link is called a reference key. Normally, this key is a foreign key in the primary table. When you select a secondary table, the tool checks for a foreign key between the primary and secondary tables. If a foreign key exists, it is displayed as the reference key by default. If the database schema has not defined a foreign key, you need to specify a reference key between the two tables.
A secondary table differs from relationships. You use secondary tables when you want columns from another table to be fields in the same bean. You use relationship fields when there is a logical relationship between tables. For example, if you want the entire row of another table to be an object in the same bean, you would map that with a relationship.
See also | |
---|---|
Mapping |