Skip to main content
Model types

Learn about Betty Blocks model types, their characteristics and features.

Updated over a week ago

Models serve as the foundation for organizing and managing data within an application or database. In addition to traditional data models, concepts such as remote models and schema models play key roles in handling data from external sources and defining data structures within a database.

To effectively use the power of data modeling, it is important to grasp the key concepts of properties and relations that govern how data is structured and interconnected. This article explains the basics and features of data, remote, and schema models.

Model types explained

You can choose between three model types: data model, schema model and remote model when creating a new model. Each of them is used for specific purposes in your application.

Data model

Data models are native to the Betty Blocks platform and are fundamental for organizing and structuring the data within your application. These models define how data is stored in the database and how various pieces of data relate to one another.

Data models consist of properties, that define the attributes of the data, such as price, name, duration, etc. These properties can point to various property types of data such as numbers, text, images, and files.

Models can define relations between different entities, enabling you to create complex data structures that reflect real-world scenarios.

Example: Imagine creating an application for a news company. Your website needs a structured data logic for storing articles, their categories, author information, etc. All this data is created and managed within one application, therefore you choose to use data models: Article, Author, Category.

Take the Article model and add the properties:

  • Name - Text (single-line) - used for storing article names in a database

  • Body text - Text (multi-line) - utilized for an article's main text

To assign authors to articles, you have to create a relation between models in the canvas view. It enables you to see all models with properties, and most importantly - how they relate to one another. For example, connecting Author to Article with Has many type of relation means: One author has many articles.

Schema model

Schema models are designed as temporary storage structures that help in organizing and processing data before passing it to other parts of your application. These models can handle multiple values for a single property and are used within native data models.

Schema models cannot be directly configured but can be utilized within native data models to handle complex data sets.

Example: In a news application, a common feature is the ability to search for articles.

The SearchQuery schema model can temporarily store search results, allowing for quick retrieval and display without permanently storing the search data.

Schema model properties are added the same way as data models but their types are limited to Text (single-line), Number, Number with decimal and Checkbox. For this case, let's add Query text (Text (single-line)) and Search results (Number).

Learn more about schema models in this article.

Remote model

Remote models allow you to integrate external data, enriching your application with additional content from various remote sources. Remote models work similarly to the native data models in terms of mapping data to your application. However, they use external data sources such as SAP Hana, Google Sheets, Microsoft Graph - Teams, etc.

To use remote models, you need to have the data source created or installed in your application via the Block Store as data source blocks.

Example: Integrating Adobe Sign as a remote model in a Betty Blocks news application allows you to manage and track document signatures directly within your application. This can be useful for handling contracts, agreements, and consent forms related to your news content and operations.

You can select the needed data source from the configuration window when creating a new remote model. After selecting and filling out the names for selected models, your remote model will be created with all predefined properties for such a model. It's possible to change only their properties' labels and remote names but not the property type.

Most cases of using remote sources include retrieving data from the external API. It is handled via Actions with the help of the HTTP(s) step. Details can be found in this article.

Also, see Updating remote data sources article to find out how to work with remote data in the long term.

Model relation types

In the current version of Betty Blocks, model relations are used only in native data models to define how they connect and interact with one another. These relations are essential for structuring your data and ensuring interactions within your application.

In the previous section, we've shown how you can work with relations in canvas view. You can also find relations of a single data model by heading to Models - [Your model]/ Articles - Relations tab.

There are three primary relation types you can use:

1. Has many: This relation indicates that one object (Author) of the source model is related to multiple objects (Articles) of the target model.

Author has many Articles

2. Belongs to many: This relation is used when multiple objects as defined in the source model are related to a single object as defined by the target model, and vice versa.

Article can belong to many Tags, and a Tag can belong to many Articles

3. Has and belongs to many: This is a many-to-many relation. Multiple objects of the source model are related to multiple objects of the target model.

Authorcan write multiple Articles but an Article can also be written by many Authors

More information about relations can be found in Working with data model schema view.

Are relations possible between different model types?

Currently, relations can only be established between data models. Remote models and schema models cannot be directly related to one another or to data models. However, you can still work with remote and schema model data through action flows. These action flows allow you to manipulate data by turning it into variables and using action steps (functions) to process and integrate it into your application.

For instance, data from a remote model (like Adobe Sign) can be fetched, transformed into variables, and then used within an action flow to update a data model or perform other operations. Similarly, schema models can handle temporary data within action flows before it is stored or utilized elsewhere in the application. This flexibility ensures that you can still effectively manage and integrate various data types in your Betty Blocks applications.



Did this answer your question?