domainmodel

0
we can use both one to one associations or generalization so when to use  one to one association and generalization
asked
3 answers
7

Hey Manikanth,

You might wanna look at this document,

https://docs.mendix.com/refguide7/generalization-and-1-1-association/

 

Hope it helps!

answered
7

Hi Manikanth Sama, 

 

Both inheritance and one-to-one associations have their advantages and disadvantages. Based on your situation you need to decide what is better for a particular entity.

There are, however, a few situations where a clear answer can be given:

  • Use one-to-one associations for entities with:

    • a high number of transactions on the different sub entities (we consider multiple changes or creates per second as being high)
    • only a handful common attributes — if you feel that it isn’t worth creating associated objects for the information, it isn’t worth inheriting either
  • Use inheritance for entities:

    • that always require the information from the associated objects, and users intensively search and sort on the associated attributes

 

Additionally you can find more information from this mendix document.. 

https://docs.mendix.com/refguide/generalization-and-association/

 

Hope this helps you. 

answered
0

Database - Inheritance

When one specialized entity is inherited from the generalized entity then the database only contains two tables, one table for each entity.

DataBase  - One-One

When there is a one to one relation then the database contains 3 tables.

Performance
both options will have a different performance impact.
When dealing with inheritance, on the retrieve of a specialization, all data will be retrieved from two tables.

When dealing with a 1-1 association, only the queried entity data is retrieved,  Associated data isn’t retrieved by default and thus there is a smaller impact on data transfer when retrieving only one of the two entities. However, if both entities are always retrieved, all three tables must be retrieved which is slower (Huge issue in performance) than the optimized two-table setup of inheritance.

With a 1-1 association, you only retrieve/change what you need, which is faster than an inheritance scenario when managing the entities individually. Inheritance will always retrieve/change from both entities.
Or do you always need both entities? If yes, then inheritance will be the best solution. Inheritance is better and quicker compared to a 1-1 association when retrieving both entities since the platform has optimized the retrieves and commits of the inheriting entities.

Conclusion:

Inheritance and 1-1 associations have their pros and cons. Thus, the best option is based on your needs and what is best for your situation. Here are a few questions that will help determine which to use:

  1. Is the specialization equal to the parent entity, and should it always be considered a single object?
    • Yes: use inheritance
    • No: use 1-1 association
  2. Are there a lot of retrieves and commits in both tables in the same transaction?
    • Yes: use inheritance
    • No: use 1-1 assocition
  3. Are there only a handful of common attributes?
    • Yes: use 1-1 association
    • No: use inheritance
answered