Make more use of database constraints - Mendix Forum

Make more use of database constraints

5

Trivial database constraints that are freely available in any RDBMS must be implemented yourself in Mendix. And guaranteeing data integrity is hard, because of possible race conditions between MFs. E.g. association functionality in Mendix does not guarantee data integrity. It is fairly easy to create a technically corrupt database with concurrent MFs with respect to associations (reference to non-existing object).

Add the following constraints to Mendix relying on the RDBMS:

  1. Uniqueness constraints on combined attributes.
  2. Uniqueness constraints on foreign key in combination with attribute. E.g. unique sequence number in order line per order (association from order line to order and sequence number attribute).
  3. Uniqueness constraint on combined foreign keys. E.g. student can subscribe to course only once (two associations from subscription to student and course).
  4. Foreign key constraint for 1-1/1-N associations without the association table (better performance, cleaner database schema, guaranteed reference).
  5. Not-null foreign keys. Define associations as required. E.g. an order line may not exist without order.
  6. Delete cascade and delete check. Associations do not guarantee data integrity.

 

asked
0 answers