Object/Relational Modeling

The most basic question facing the object-oriented developer using a relational database is how to map relational data into objects. Your immediate thought might be to simply map object attributes to fields in a table. Unfortunately, this approach does not create the perfect mapping for several reasons.

  • Objects do not store only simple data in their attributes. They may store collections or relationships with other objects.

  • Most relational databases—MySQL and mSQL among them—have no way of modeling inheritance.

Think about that address book we talked about earlier. We probably have something like the address and person tables shown in Figure 8.2.

Note

The least apparent issue facing programmers is one of mindset. The basic task of object-oriented access to relational data is to grab that data and immediately instantiate objects. An application should only manipulate data through the objects. ...

Get MySQL and mSQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.