Skip to main content
Version: 2.8

Data - Data Models

Introduction

Data Models are a way to represent business objects into an application.

A Data Model is composed of Data Types and relationships between them. Properties can be added to these models and they can be connected together in order to create relations:

new_business_model

Properties and Relations

Properties are the attributes that have the same lifecycle as the object: when the object is deleted, the property is deleted.

new_property

Relations are the attributes that have a different lifecycle as the object: when the object is deleted, the related object is not deleted. Moreover, it is possible to link more than one object within a single relation: new_relation

Best practices

Use Strong Typing when defining a Data Model. E.g. : A model which has a temperature property should have a property of type “Temperature” (≠Number). Temperature can then be used independently of the unit (celsius, fahrenheit, …).

Define then functions to get the value as a number: E.g Temperature as °F, Temperature as °C, ...

Exercise 7 – Notes data model

The goal of this exercise is to create the data model of the "Notes" app. exercise_7_result

  1. Go to Project “Notes”.
  2. Open Folder “Data”.
  3. Create a new Data Model named “Notes Data Model”.
  4. Open the new Data Model.
  5. Create a Data Type named “Note”:
    • Add String property “Summary”
    • Add String property “Content”
  6. Create a Data Type named “Category”:
    • Add String property “Name”
  7. Create a relation from Data Type “Note” to Data Type “Category” by dragging&dropping the "Category" model from the Marketplace to the "Note" Relations field. Name it ”Category”. While this relation is not used later in this exercise, this shows the concept and how it is done.