Advanced Domain Modeling and Data Structure
What the exam tests
This domain checks whether you can shape a domain model that survives change: inheritance, association choice, constraints, indexes and event handlers. Questions are usually scenario-based - a model is described and you pick the design that keeps queries fast and data consistent.
Entities, inheritance and associations
Mendix stores a generalization as one table with a discriminator, so an XPath on the parent also returns every subtype. Prefer shallow hierarchies: each level adds joins and makes filters on subtype attributes slower. Use a reference association for one-to-many and a reference set for many-to-many (it creates a separate join table). The association owner stores the foreign key; switching the owner later changes the schema and needs a migration.
Constraints, indexes and events
Required and unique are validation rules evaluated at commit; unique needs a database index, declared on the entity's Indexes tab. Index every attribute you filter or sort on in XPath. Event handlers (before/after create, commit, delete) run on every commit unless you commit without events - the right place for defaults and audit fields, not for heavy integration calls. Calculated attributes are not persisted and cannot appear in XPath.
Worked example
An Order has a reference to Customer and a reference set to Product. Deleting an order must delete its lines, deleting a customer must not delete orders, and deleting a product must never cascade. Reasoning: the OrderโOrderLine association is set to delete OrderLine objects; CustomerโOrder keeps the default; a reference set cannot own the cascade because other orders still reference the product, so ACT_DeleteProduct checks open order lines and blocks.
Traps
Filtering on a subtype attribute in an XPath on the parent reads the whole hierarchy; adding unique without an index; putting business rules in a before-commit handler that then runs again on every list commit; assuming reference sets behave like references for delete behaviour.