Recommendations for Mapping Relational Data to Business
Entities
To map relational data to business entities, consider the following
recommendations:
- Take the time to analyze and model the logical business entities of your
application, rather than defining a separate business entity for every table.
One of the ways to model how your application works is to use Unified Modeling
Language (UML). UML is a formal design notation for modeling objects in an
object-oriented application, and for capturing information about how objects
represent automated processes, human interactions, and associations. For more
information, see Modeling
Your Application and Data.
- Do not define separate business entities to represent many-to-many tables
in the database; these relationships can be exposed through methods
implemented in your Data Access Logic Component. For example, the OrderDetails
table in the preceding example is not mapped to a separate business entity;
instead, the Orders data access logic component encapsulates the OrderDetails
table to achieve the many-to-many relationship between the Order and Product
tables.
- If you have methods that return a particular type of business entity,
place these methods in the Data Access Logic Component for that type. For
example, if you are retrieving all orders for a customer, implement that
function in the Order Data Access Logic Component because your return value is
of the type Order. Conversely, if you are retrieving all customers that have
ordered a specific product, implement that function in the Customer Data
Access Logic Component.
- Data access logic components typically access data from a single data
source. If aggregation from multiple data sources is required, it is
recommended to define a separate Data Access Logic Component to access each
data source that can be called from a higher-level business process component
that can perform the aggregation. There are two reasons for this
recommendation:
- Transaction management is centralized to the business process component
and does not need to be controlled explicitly by the Data Access Logic
Component. If you access multiple data sources from one Data Access Logic
Component, you will need the Data Access Logic Component to be the root of
transactions, which will introduce additional overhead on functions where
you are only reading data.
- Aggregation is usually not a requirement in all areas of the
application, and by separating the access to the data, you can let the type
stand alone as well as be part of an aggregation when needed.