Skip to main content

Data - Data Models

Introduction#

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

A Data Model is composed of Business Models 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 1 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 Business Model named “Note”
    • Add String property “Summary”
    • Add String property “Content”
  6. Create a Business Model named “Category”
    • Add String property “Name”
  7. Create a relation from Model “Note” to Model “Category” and name it ”Category”