# Data Modelling

## Introduction

The Class Designer is the central unit to build a new application. It is used to define the classes that model data in an application. A class typically consists of fields, actions and links - each of which can be thoroughly configured using the class designer.

![Class designer window](/files/-MAwrEz-oVcdFylQ8Szh)

## Manage Classes

You can edit (by selecting details), delete, clone or export existing classes for use in another application easily from the dropdown menu for your class. More options are available in the toolbar as well.

### Editing a class

The class editor can be opened by selecting **Details** from its dropdown menu.

![Class designer: Edit a class](/files/-MBJbyJJKnFXEUOwmgeR)

The class editor allows you to modify the configurations of your class. More details about the different sections and attributes that help you customize you class can be found [here](/building-an-application/data/data-modelling/class.md).

### Deleting a class

A class can be deleted simply by selecting the **Delete** option from its dropdown menu.

{% hint style="danger" %}
Important: The system does not prompt for confirmation during deletion.
{% endhint %}

![Class designer: Deleting a class](/files/-MBG7Rb9WsLy08e94dGs)

### Cloning a class

A class can be cloned by selecting the **Clone** option from its dropdown menu. A new class with the same properties as the original class is created in your application.

The `- Copy` suffix is added to the class name to prevent conflicts with the original class.

![Class designer: Cloning a class](/files/-MBG7YSaqYIaFDeEk_gv)

{% hint style="danger" %}
Note that when cloning a class, unique properties such as the [Common Key](/building-an-application/data/data-modelling/class.md#key) and [Mapping Key](/building-an-application/data/data-modelling/class.md#key-1) also retain the same values as the original class, rendering the clone as invalid.

Make sure to modify all unique properties of the class to allow saving your cloned class.
{% endhint %}

## Class Diagram

A class diagram can easily be generated and viewed in the class designer itself by selecting your classes from the left panel. Alternately, you can select **Show All Classes** (from the toolbar) to generate a diagram with all the classes in your application.

![Class designer: Creating class diagrams](/files/-MBG7hdnG4qv3-Q53CfA)

#### Alignments

By selecting the **Align Elements** option, you can select to display your class diagram in different layouts. The options include **Circle**, **Square** and **Columns**.

![Class designer: Elements aligned in circular layout](https://firebasestorage.googleapis.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8HTRblOKav_qm4KEx6-887967055%2Fuploads%2FWsxrJGJQQgUTznuXi0yR%2Ffile.jpeg?alt=media)

## Import and Export

Individual classes can be exported by selecting **Export** from their dropdown menus.

Alternately, you can choose to click on the general **Export** option in the toolbar and select all the classes you wish to export. Click on **Execute** to complete the operation.

Both methods result in a your class definitions compiled to JSON files being downloaded as a ZIP file.\
The default file name is `classes.zip`.

{% hint style="info" %}
The generated ZIP file may be password-protected.
{% endhint %}

![Class designer: Exporting classes](/files/-MBG7rhBFQOobwznwLmf)

Similarly, classes can be imported in an application by selecting **Import** from the toolbar and selecting your class definition JSON files. Click on **Execute** to complete the operation.

## Validate and Save

You can also check the validity of your classes by selecting the **Validate** option or save your current classes by selecting **Save** from the bottom menu.

![Class designer: Validate and save class](/files/-MBG83YJ0ZTn9NW3-Xwe)

All validation errors are displayed in the collapsible log at the bottom.

{% hint style="danger" %}
In case your class is invalid, the system will not allow the class to be saved.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tivity.one/building-an-application/data/data-modelling.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
