Top 10 Must Have Features in O/R Mapping Tools
Feature 4: Relationships and life cycle management
The foundation of a relational database is that tables have relationships with other tables. Similarly, when you map objects to these tables, your objects also need to establish the same relationships with other mapped objects. Therefore, your O/R mapping tool must support this very important feature by letting you determine which relationships you want to keep in your objects. Below are the different types of relationships you must have:
- One-to-one relationship
In this, your object must contain a reference to exactly one other object and must handle load and save scenarios for it. - Many-to-one relationship
This is very similar to one-to-one where your object must contain a reference to exactly one other object and must handle load and save scenarios. - One-to-many relationship
In this, your object must contain a collection of the related objects and must handle loading them with load and also adding and removing them with save operations. - Many-to-many relationship
This is the most complex relationship and involves a bridge table in the database to establish the relationship. There are two different situations for the bridge table as described below:- Bridge table with only primary key
In this situation, the bridge table contains only the primary key (which is actually composed of multiple foreign keys). So, your object need not have any bridge table attributes and only needs to keep a collection of the related objects (similar to one-to-many). In fact, the public interface of your object is usually identical to one-to-many but the underlying code is different because of the bridge table. - Bridge table with additional columns
This is the most complex situation because the bridge table has additional useful columns that your object must cater for. Your object needs to load a collection of composite objects containing both the bridge table and the related table information. The life cycle management feature must include the ability to load a primary (or parent) object and through this object load all the related objects (meaning all the different relationships). You should also be able to add newly created related objects or remove existing related objects from the relationships. And, when you save the primary object, it must save all the relationship information along with it (as one transaction). A good O/R mapping tool would let you define all types of relationships and also handle life cycle management in the generated code.
- Bridge table with only primary key
Previous Page | Next Page
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8
If you found this page useful, bookmark and share it on:
If you are familiar with RSS feeds, you can also sign up for our free blog feed. Our RSS feed is updated in real-time while our newsletter is updated daily.
