Specifics on Mapping Objects to Tables
Mapping objects to tables involves creating or updating data stored in a relational database. This figure illustrates such a mapping. The details of mapping involve:
- Mapping objects to one or many tables. There are usually multiple ways to
map objects to tables. The issues include:
- Mapping inheritance issues. Is the inheritance structure mapped to multiple tables or is it mapped to one table with multiple type codes?
- Determining how many classes per table. Sometimes a given class might be stored as multiple tables or vice versa.
- Making decisions related to the potential for redundant data. Since object models do not need foreign keys or intersection entities, using them in a relational database, in a sense, is creating redundant data.
- Designing for multi-table updates. The prior issues often create the need for updating multiple tables.
- Mapping collection classes into tables. Decisions need to be made if a collection is mapped to one or more tables.
- Mapping object types to database data types. In most cases this is straightforward mapping.
- Mapping object relationships to keys or intersection tables. This is the many-to-many relationship issue that is represented in a relational database as an intersection table.
More on the general topic: Mapping