Domain Model in the Metamodel

Last update: Download PDF Edit

1 Introduction

The domain model represents the data that is stored in your app. Each module has a domain model, consisting of entities, which have attributes of a certain type and associations with other entities.

Attributes have a value which can either be a StoredValue, which is a value stored in the database, or a CalculatedValue, which is computed from a Microflow.

The entities can also relate to each other through generalizations. Finally, you can define access rules, validation rules, event handlers and indexes for entities.

1.1 Graphical Overview

Studio Pro Guide Model SDK API Docs
Domain Model TypeScript module domainmodels
Entities DomainModel
Attributes Entity
Associations Association

2 Attributes

Entities can have multiple attributes. Each attribute has a specific type.

2.1 Graphical Overview of Non-Numeric Attributes

2.2 Graphical Overview of Numeric Attributes

Studio Pro Guide Model SDK API docs
Attributes Property attributes of entity

3 Generalization Relationships

Entities can have a Generalization relationship with another entity. The entity is then called a Specialization. A specialization entity inherits all attributes, validation rules and access rules from its Generalization entity.

An Entity instance has a generalization property with which to define this relationship. It can either be set to a NoGeneralization instance if it is not a specialization of another entity, or it can be set to a Generalization instance. A Generalization instance has again a generalization property which must point to the entity that is the actual generalization.

3.1 Graphical Overview

Studio Pro Guide Model SDK API docs
Entities Property generalization of Entity

4 Access Rules

To secure access to the data in a Mendix app, you can define access rules for entities. An access rule is always defined for a certain module role, defines to which attribute or association members that role has access, and the retrieved data is constrained by an xpath constraint.

4.1 Graphical Overview

Studio Pro Guide Model SDK API docs
Access rules Property accessRules of Entity
Property xpathConstraint of AccessRule

5 Validation Rules

For each attribute of an entity, it is possible to define a validation rule. The validation rule is applied to a single attribute, will show some error message, and it is a certain type of rule, e.g. the attribute needs to be equal to a certain value, or has a maximum length, or needs to be unique.

5.1 Graphical Overview

Studio Pro Guide Model SDK API docs
Validation Rules Property validationRules of Entity

6 Indexes

An entity can have multiple indexes. Each index consists of a set of indexed attributes.

6.1 Graphical Overview

Studio Pro Guide Model SDK API docs
Indexes Property indexes of Entity