segunda-feira, 13 de julho de 2015

Mapping types of ATG repository

The mapping a repository is very important in a database design, because if it is not done correctly, you may not be able to set-up your repository XML correctly, and if this is not done, you'll never be able to figure out what went wrong, or why your repository is functioning properly. Let us pick up various mapping topics and learn when to use them.

One-to-one Mapping

Consider an example, wherein there is an "Employee". An employee can only be associated with exactly one "homeAddress" at a time. And, conversely, a "homeAddress" can only have one "employee". This is basically referred to as one-to-one mapping.

One-to-many Mapping

Consider a similar example, where an "Employee" has many "credit cards". But a particular credit card can be associated with exactly one "Employee". See below diagram for more details:

Many-to-one Mapping

Many-to-one mapping is similar to above example, but is the opposite. Here, consider an "Employee" can be associated with one "Organization", but an "Organization" can have many employees.
See below diagram for more clarity:

Many-to-many Mapping

Many-to-many mapping is simply the concept of many entities being associated with many entities. For example, An "Employee" can be a part of multiple "meetings" during the day, and a "meeting" can have multiple "Employees" associated with it. See below diagram for details:

Now that we know which mapping to choose for our requirements, we can to design patterns for database and repository for each of these types.


What mapping should you choose for extending ATG repository?

Nenhum comentário:

Postar um comentário