training course domain modeling. 2 what is the domain model? an abstract data model a reflection of...
TRANSCRIPT
![Page 1: Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists](https://reader035.vdocuments.mx/reader035/viewer/2022062301/5697bfe91a28abf838cb6d3c/html5/thumbnails/1.jpg)
Training Course
Domain Modeling
![Page 2: Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists](https://reader035.vdocuments.mx/reader035/viewer/2022062301/5697bfe91a28abf838cb6d3c/html5/thumbnails/2.jpg)
2
What is the Domain model?
•An abstract data model•A reflection of reality•No ERD, closer to entity-oriented models•Consists of entities, attributes and associations
![Page 3: Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists](https://reader035.vdocuments.mx/reader035/viewer/2022062301/5697bfe91a28abf838cb6d3c/html5/thumbnails/3.jpg)
3
What is an entity?
•Something that exists in real life•“Blueprint for Mendix entities”
Examples:•Car•House•Client•Order•Product•Email message
![Page 4: Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists](https://reader035.vdocuments.mx/reader035/viewer/2022062301/5697bfe91a28abf838cb6d3c/html5/thumbnails/4.jpg)
4
How to add an entity?
•Click on the “Entity” button•Click on the desired location•Set the name of the entity in the “Properties” window
![Page 5: Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists](https://reader035.vdocuments.mx/reader035/viewer/2022062301/5697bfe91a28abf838cb6d3c/html5/thumbnails/5.jpg)
5
What is an attribute?
•“Provides information about an Entity”
•Client ← Name, Address, City•Car ← Brand, Type•Order ← OrderNumber, OrderDate
![Page 6: Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists](https://reader035.vdocuments.mx/reader035/viewer/2022062301/5697bfe91a28abf838cb6d3c/html5/thumbnails/6.jpg)
6
Attribute types
• AutoNumber (Automatically incrementing number)• Binary• Boolean (True or False)• Currency• DateTime• Enumeration (Collection of predefined values)• Float (Floating-point number: 1.12)• HashString• Integer (Small number)• Long (Big number) • String (Text)
![Page 7: Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists](https://reader035.vdocuments.mx/reader035/viewer/2022062301/5697bfe91a28abf838cb6d3c/html5/thumbnails/7.jpg)
7
How to add attributes to an entity?
•Double click on an entity•Go the ‘Attributes’ tab page•Click on the “Add” button•Enter the “Name”•Select “Type”
![Page 8: Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists](https://reader035.vdocuments.mx/reader035/viewer/2022062301/5697bfe91a28abf838cb6d3c/html5/thumbnails/8.jpg)
8
What are associations?
•“Indicates the relationship between entities”
•Car – Owner•Order – Client•Product – Product group•Book - Author
![Page 9: Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists](https://reader035.vdocuments.mx/reader035/viewer/2022062301/5697bfe91a28abf838cb6d3c/html5/thumbnails/9.jpg)
9
Association types
•Basic– Reference
•Advanced– Reference Set – 1-1 Reference (Reference BOTH)– MN Reference (Reference Set BOTH)
![Page 10: Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists](https://reader035.vdocuments.mx/reader035/viewer/2022062301/5697bfe91a28abf838cb6d3c/html5/thumbnails/10.jpg)
10
What is a reference?
•With a reference you can refer from one entity to another entity•In the given example the customer refers to country•The ‘1 to 0’ reference is the most common kind of association•Similar to ERD 1 – n relations
• Customer refers to 1 Country • Country can be referenced by multiple customers• The reference is stored in the Customer• The cardinality can be read as follows:
Customer refers to 1 country Country refers to 0 customers
![Page 11: Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists](https://reader035.vdocuments.mx/reader035/viewer/2022062301/5697bfe91a28abf838cb6d3c/html5/thumbnails/11.jpg)
11
Reference in XML
The reference is stored in the owner of the association which is indicated by the arrow (‘Order’ in the given example)
<Customer id="101"><Name>KLM</Name><Customer_Country>id_201</Customer_Country>
</Customer>
<Country id="201”><Name>Holland</Name>
</Country>
![Page 12: Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists](https://reader035.vdocuments.mx/reader035/viewer/2022062301/5697bfe91a28abf838cb6d3c/html5/thumbnails/12.jpg)
12
How to add a reference?
•Click on the “Add association” button•Click on the border of the meta entity (starting at the owner)•Keep the mouse button pressed•Drag the association to the border of the other entity
![Page 13: Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists](https://reader035.vdocuments.mx/reader035/viewer/2022062301/5697bfe91a28abf838cb6d3c/html5/thumbnails/13.jpg)
13
What is a reference set?
•With a reference set one entity refers to multiple other entities•In the example the Customer refers to many Groups•Similar to ERD ‘N – M relations’
• Customer refers to N groups• Group can be referenced by multiple customers• The relation is recorded in the customer• The cardinality can be read as follows:
Customer refers to N groups Group refers to 0 Customers
![Page 14: Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists](https://reader035.vdocuments.mx/reader035/viewer/2022062301/5697bfe91a28abf838cb6d3c/html5/thumbnails/14.jpg)
14
Reference set in XML
<Customer id="101"><Name>General Motors</Name><Customer_Group>id_201 id_202</Name>
</Customer>
<Group id="201”><Name>VIP</Name>
</Group>
<Group id="202”><Name>Christmas cards</Name>
</Group>
The reference is stored in the owner of the association which is indicated by the arrow (Customer in the given example)
![Page 15: Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists](https://reader035.vdocuments.mx/reader035/viewer/2022062301/5697bfe91a28abf838cb6d3c/html5/thumbnails/15.jpg)
15
How to add a reference set?
•Add an association•Click on the association•Set the property “Type” to “ReferenceSet”
![Page 16: Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists](https://reader035.vdocuments.mx/reader035/viewer/2022062301/5697bfe91a28abf838cb6d3c/html5/thumbnails/16.jpg)
16
What is a reference both?
•This indicates that two entities always belong together•Could also be modeled as one large entity•In the example the customer refers to a profile and profile to customer•Similar to ERD ‘1 – 1 relations’
• Customer refers to 1 profile• Profile then always refers to the same Customer• The relation is stored in both Customer and Profile• The cardinality can be read as follows:
Customer refers to 1 Profile Profile refers to 1 Customer
![Page 17: Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists](https://reader035.vdocuments.mx/reader035/viewer/2022062301/5697bfe91a28abf838cb6d3c/html5/thumbnails/17.jpg)
17
Reference both in XML
<Customer id="101"><Name>General Motors</Name><Customer_Profile>id_201</Customer_Profile>
</Customer>
<Group id="201”><Name>Profile_General Motors</Name>
<Customer_Profile>id_101</Customer_Profile></Group>
The reference is stored in the owner of the association which is indicated by the arrow (both Customer and Profile in the example)
![Page 18: Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists](https://reader035.vdocuments.mx/reader035/viewer/2022062301/5697bfe91a28abf838cb6d3c/html5/thumbnails/18.jpg)
18
How to add a reference both?
•Add an association•Click on the association•Set the property “Owner” to “Both”
![Page 19: Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists](https://reader035.vdocuments.mx/reader035/viewer/2022062301/5697bfe91a28abf838cb6d3c/html5/thumbnails/19.jpg)
19
What is a reference set both?
•With a reference set both, both entities refer to multiple other entities•In the given example, the Customer refers to many Groups and vice versa•Similar to ERD ‘N – M relations’•Hardly ever used
• Customer has maximum of N groups and vice versa• Group can belong to multiple customers and vice versa• The relation is stored in both Customer and Group• The cardinality can be read as follows:
Customer refers to N groups Group refers to N Customers
![Page 20: Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists](https://reader035.vdocuments.mx/reader035/viewer/2022062301/5697bfe91a28abf838cb6d3c/html5/thumbnails/20.jpg)
•If one entity is deleted, an associated entity is deleted as well•This is commonly used by – Reference both associations– When one entity in reality is modeled as two entities,
for example: Order & OrderLine
•Can be defined on both the parent or the child of the association•In the given example, the Profile will be deleted when the Customer is
deleted
20
What is cascading delete?
![Page 21: Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists](https://reader035.vdocuments.mx/reader035/viewer/2022062301/5697bfe91a28abf838cb6d3c/html5/thumbnails/21.jpg)
•Select the association•Click the ... Button in the “Delete behavior” in the explorer•Select the desired delete behavior (2nd radio button)
21
How do I configure cascading delete?
![Page 22: Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists](https://reader035.vdocuments.mx/reader035/viewer/2022062301/5697bfe91a28abf838cb6d3c/html5/thumbnails/22.jpg)
•This prevents an entity from being deleted if it is referenced by other entities
•This prevents the existence of orphans or invalid references in the database
•A message to the end user can be specified for each association•Always specify a message when blocking a delete•In the given example, a Country can’t be deleted if it is referenced by a
Customer
22
What is delete prevention?
![Page 23: Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists](https://reader035.vdocuments.mx/reader035/viewer/2022062301/5697bfe91a28abf838cb6d3c/html5/thumbnails/23.jpg)
•Select the association•Click the ... Button in the “Delete behavior” in the explorer•Select the desired delete behavior and enter a message for the end
user
23
How do I configure delete prevention?
![Page 24: Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists](https://reader035.vdocuments.mx/reader035/viewer/2022062301/5697bfe91a28abf838cb6d3c/html5/thumbnails/24.jpg)
24
Combining cascading delete & delete prevention
Question:
What happens if a continent is deleted that contains countries with customers?
Countries can only be deleted if they are not referenced by any customer
If a continent is deleted all countries are deleted as well
![Page 25: Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists](https://reader035.vdocuments.mx/reader035/viewer/2022062301/5697bfe91a28abf838cb6d3c/html5/thumbnails/25.jpg)
•Before an entity is committed all validations rules are checked•Validation rules apply to attributes•If one rule is violated then the commit action will be cancelled•For each rule you can specify an error message •All messages are returned to the caller •If the caller is the client portal, the messages will be shown in the data
view•Validation rules are visualized in the model (green check next to attribute)
25
What are validation rules?
![Page 26: Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists](https://reader035.vdocuments.mx/reader035/viewer/2022062301/5697bfe91a28abf838cb6d3c/html5/thumbnails/26.jpg)
•There are different kinds of validation rules:– Required The attribute is required to have a value– Unique The values of this attribute is unique across all instances of
an entity– Equals The value equals a predefined value or other attribute– Range The value lies between two other values
(other attributes or fixed values)– Regular expression The value conforms to a regular expression– Maximum length There is a maximum length for the attribute
26
What are validation rules?
![Page 27: Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists](https://reader035.vdocuments.mx/reader035/viewer/2022062301/5697bfe91a28abf838cb6d3c/html5/thumbnails/27.jpg)
•Double click on the entity•Open tab page “Validation rules”•Click the “Add” button
27
How to configure validation rules?
![Page 28: Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists](https://reader035.vdocuments.mx/reader035/viewer/2022062301/5697bfe91a28abf838cb6d3c/html5/thumbnails/28.jpg)
•Select the attribute•Define an error message, that is shown when the rule is violated•Select the type of validation rule•Set the necessary values•Click OK
28
How to configure validation rules?
![Page 29: Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists](https://reader035.vdocuments.mx/reader035/viewer/2022062301/5697bfe91a28abf838cb6d3c/html5/thumbnails/29.jpg)
•A term ‘borrowed’ from Entity-Oriented programming•A subentity inherits from a superentity.•The subentity inherits all attributes including validation rules
and associations of the superentity. •The superentity is extended, also called specialization•In the example both Customer and Employee are
specializations from User
29
What is Generalization?
![Page 30: Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists](https://reader035.vdocuments.mx/reader035/viewer/2022062301/5697bfe91a28abf838cb6d3c/html5/thumbnails/30.jpg)
•Customer has the attributes: – Address– Name– Password
•Employee has the attributes:– Function– Name– Password
30
What is Generalization?
![Page 31: Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists](https://reader035.vdocuments.mx/reader035/viewer/2022062301/5697bfe91a28abf838cb6d3c/html5/thumbnails/31.jpg)
•Select the entity in the Domain model•Click on the … button of the property “Generalization”•Select the superentity in the explorer popup•Click Select
31
How do I configure inheritance?
![Page 32: Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists](https://reader035.vdocuments.mx/reader035/viewer/2022062301/5697bfe91a28abf838cb6d3c/html5/thumbnails/32.jpg)
•When entities have a number of common attributes (keeps the model clear)•When entities can be generalized as a super entity•When you want to use functionality from another module (e.g. the System model)•When two entities need to be displayed in one list (only shows the common attributes)
32
When to use Generalization?
![Page 33: Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists](https://reader035.vdocuments.mx/reader035/viewer/2022062301/5697bfe91a28abf838cb6d3c/html5/thumbnails/33.jpg)
•Performance reduction through complex joins on database•Challenging when used in combination with complex business logic
and validation rules•It becomes difficult to oversee implications of changes to the
domain model when a lot of generalization is used
33
Generalization Drawbacks