Skip to main content

Data Model

Entity / Data Module is the tool that helps you to easily model the services that you will need in your application.

Getting Started

To start modelling the service:

  • Click the Add button on the right side of the module and select Data Model.

You can think of an entity as a table and its fields as columns of the table to keep information. enter image description here enter image description here

  • Give your data model a name that starts with lowercase.

enter image description here

Voilà! You have a data model that you can customize. enter image description here

Now, you can add a Data Model from upper left corner on the Explorer window. This creates a data model by default. You can change the name of the data model by clicking on the name.

enter image description here

  • To add a new field to your data model, click Add field button.

enter image description here

You can change the field name by clicking on the name and the field type by clicking the combobox on the right.

enter image description here

You can delete or duplicate the entity from the menu opened by the three dots on the right bottom corner.

enter image description here

Enums

In data modeling, an "enum" is a data type that represents a fixed set of values. The term "enum" stands for "enumeration," which means a listing of named items.

An enum is typically used when you have a data attribute that can only take on a limited number of values, which are known at design-time. Examples of such attributes include status codes, types of objects, and days of the week. Defining an enum for these values can help to enforce data consistency and improve readability and maintainability of code.

You can add a new enum from upper left corner.

enter image description here

Genre is a good example for our book example.

enter image description here

You can add the enum as a field type in an entity.

enter image description here

Operations

After creating your first entity, you can start creating operations. When you select the entity that you want to create operations for, on the right panel, under Operations tab, you can see five main operations: get, getAll, create, update and delete.

enter image description here

By switching each operation's switch on and off, you can decide which operations your entity will have. Create: POST request to create an entity. Delete: DELETE request to delete the entity given id. Update: PATCH request to update the entity given id. Get: GET request to fetch the entity given id. GetAll: GET request to fetch all entities created.

Custom Operations

Although these five operations generally meet most of your operational needs, you might sometimes need to query entities by a specific field (getBooksByAuthor) or update all entities with a specific name (updateBooksByName). Custom operations let you customize the input fields for the main operations.

You can find custom operations, on the right panel under custom operations tab.

enter image description here

To create a custom operation for your selected entity, click the + icon.

enter image description here

You can see the example for the custom operation. DeleteBookByName operation queries all the Book records and deletes all records with name field equal to the name input.

enter image description here

Relations

Relations are used in Data Model to create relationships between two entities.

  1. Identifying the entities: Determine which two entities you want to create a relation between. For example, you may want to create a relation between an author and a book. To create the relation, select the entity and click the + icon on the upper right corner.

enter image description here

  1. Defining the relationship: Decide what kind of relationship you want to create between the entities. Common types of relationships include one-to-one, one-to-many, and many-to-many. You can define the type of your relationship by clicking on the relation and selecting the type from combobox.

enter image description here

There is a quick overview of what relation types are and their examplary usage.

  • One-to-One: Occurs when one instance of an entity is related to only one instance of another entity, and vice versa. For example, an employee may have only one employee ID, and that employee ID may be associated with only one employee.
  • One-to-Many: Occurs when one instance of an entity can be associated with multiple instances of another entity, but each instance of the other entity can be associated with only one instance of the first entity. For example, a customer may have multiple orders, but each order can only be associated with one customer.
  • Many-to-One: This is the reverse of a one-to-many relationship, where multiple instances of an entity can be associated with a single instance of another entity. For example, multiple orders can be associated with a single customer.
  • Many-to-Many: Occurs when multiple instances of an entity can be associated with multiple instances of another entity. For example, students can be enrolled in multiple courses, and each course can have multiple students.