After reading this article you will know:

  • What a data model is used for
  • What a data model mainly consists of
  • Some example uses for each kind

The data model is where the application stores all the information. A single model represents a part of this. The data model in your application is a visual tool with an intuitive interface. It has the following elements: models, properties, and relations.

What is the data model used for?

The application's data is defined and stored in the data model so we can use it for other application elements, as for application actions. It is the backbone of all application types you can build with the Betty Blocks platform. It describes all the data in an abstract way and hides unnecessary complexity to increase speed and flexibility. No technical knowledge of databases is needed as writing queries. The data model is visually built (drag and drop). We are taking care of the underlying database. 

The data model is logically split up into multiple models, properties and relations:

Models

Models are shown as containers in the datamodel. They represent real-world objects that are included in the application. For a webshop, for instance, a product model will be necessary to store the data of all the products, your customers, and their orders. The name of a model is written as a singular noun, so the name for a products model will be product. Every new application starts with 2 models: Role and User. These models are for the Betty Blocks users that can log in to the application so it is not advised to make changes to them.

Properties

Within the model container, the properties of that model are shown. Properties store the data in the models. What kind of data can be stored depends on the data type. This datatype defines if the data can be stored as a number, text, image, file, etc.
A new model starts with three properties, these are, created_at, updated_at and id . The id property makes every object of a model unique. If you want to know more about properties you should check out this article: Property Reference.

Relations

Models can be related to one another with relations.
These relations are used when something needs to be stored in a different model. For instance, when a customer needs to have multiple addresses a new model called address can be created. The models can call out to each other through a relation. Betty Blocks uses 3 different kinds of relations:

  • Has many
  • Belongs to
  • Has and belongs to many

More about these different kinds of relations can be found in this article: Relations Reference.

Did this answer your question?