Mapping Classes to Tables

The easiest way to translate classes into tables is to make a one-to-one mapping (see Figure 9-2). I strongly recommend against this approach, yet it is done more often than you might realize. One-to-one mapping can lead to the following problems:

Figure 9-2. Remulak class diagram

  • Too many tables: Most object-to-relational translations done with one-to-one mapping produce more tables than are actually necessary.

  • Too many joins: If there are too many tables, then logically there will be too many SQL join operations.

  • Missed tables: Any many-to-many association (e.g., Customer and Address) will require a third relational table ...

Get Developing Applications with Java™ and UML now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.