---
title: "Reference: model"
description: "Define models, fields, relationships, indexes, and display text in schema.xml."
permalink: /docs/data-model/model/
---
# Reference: model

A `<model>` in `schema.xml` defines a type of record. Give it a `name` for use in code and a `label` for people using the app, then add fields and any relationships inside it. For an introduction to how models fit together, see [What is the Data Model?](/docs/concepts/data-model/).

```xml
<model name="asset" label="Asset">
  <field name="serial_number" label="Serial Number" type="text" />
  <belongs-to model="building" />
  <index on="building" />
  <display>{serial_number}</display>
</model>
```

## Model attributes

| Name | Required | Details |
| ---------------- | ---------- | ------------------------------------------------------------------------------------------------------------------ |
| `name` | *required* | Unique identifier for this model. Used anywhere that code needs to reference the object. |
| `label` | *required* | Human-readable label for the object. Used wherever it is displayed to a user. |
| `classification` | *optional* | Specify whether a model is `sensitive` or `standard`. If this field is omitted, it will be regarded as `standard`. |

## Elements inside a model

Add these elements inside a `<model>` to define its data and behavior:

| Nested Element | Details |
| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`field`](/docs/data-model/model/field/) | Stores a value on each record. Choose a field type such as `text`, `date`, or `single-choice`. |
| [`belongs-to`](/docs/data-model/model/belongs-to/) | Defines the single parent of a record in a relationship, such as the building an asset belongs to. |
| [`has-many`](/docs/data-model/model/has-many/) | Defines a collection of related records, such as a building's assets. |
| [`index`](/docs/data-model/model/index/) | Speeds up queries on specified fields or relationships. See [App Indexes](/docs/data-model/app-indexing/) for when to use one. |
| `display` | Defines how an object should be displayed to the user by default (for example, in a list). See [XML String Formatting](/docs/get-started/syntax/xml-format-strings/) for details on the format. |

<span id="sensitive-classification" />

## Sensitive model retention

For apps that process personal data, you can classify a data model as sensitive. This ensures minimal data retention periods in order to comply with regulations like the EU's GDPR. If a model is marked as `sensitive`, all audit logs entries of objects of that model type will be deleted after 30 days. For example, if a `sensitive` object gets created, the audit log entry will be deleted 30 days after the creation date. If the object gets updated or deleted, the audit log entry for the update will get deleted 30 days after the update date.

We also store a backup of the audit log for an additional 30 days, which means that the data will be completely deleted after 60 days.

If the model's classification is set as `standard`, or isn't specified, all audit log entries for that model will be deleted after 3 years plus 30 days of backup window.
