# Data modelling

Data models are what define the structure of your content.  They define what types of content you have - such as new articles, categories, information pages - and how they interact with each other - a news article might belong to a category.

Models consist of fields.  Fields are the properties or attributes that your model possess.  A **news article** might have **title**, **date** and **content** fields.

## Creating a model

In a new project that has no models, you will be taken directly to the model creation screen.

Otherwise, you can get to the model section by using the top navigation bar: Content > Models

![](https://656338775-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M_3jgsLHkigCZJbeW1B%2F-MbcarVvnrkZZbQNSGYs%2F-MbccBUCZpvo0DgieqAH%2Fimage.png?alt=media\&token=9e2155d0-51a0-4995-8437-131f6f8b0eed)

Give your model a name, the alias will automatically populate.  If you want to change the alias you can.

|                 | Description                                                                                                                                                                                                                                                                                                          |
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Name**        | This is a friendly name for your model.  It can be changed at any time.                                                                                                                                                                                                                                              |
| **Alias**       | This is how you refer to your model when querying content.  You can change this at any time, however, it will affect any integrations you have built.                                                                                                                                                                |
| **Usage**       | This identifies the purpose of your model.  Entries are top-level content such as web pages and categories.  Modules are content that live inside other content - such as entries or nested within another module.  See [modular content](https://docs.pokko.io/advanced-features/modular-content) for more details. |
| **Inheritance** | This allows you to specify models to inherit properties from.  See [data model inheritance](https://docs.pokko.io/advanced-features/data-model-inheritance) for a deeper look into this feature.                                                                                                                     |

Click the "Save changes" button to create your model.

## Adding fields

With your model created, you can now start adding fields.  Click the "New field" button.

![](https://656338775-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M_3jgsLHkigCZJbeW1B%2F-MbcczH1H-SvNiGqhbs7%2F-Mbcf7ID9b-Z7ROg6qnf%2Fimage.png?alt=media\&token=9cb402f5-f529-41a5-be8d-71ec73fa9958)

You only need to specify the name, alias and type to create a field.  The additional configuration will be discussed in later topics.

|                            | Description                                                                                                                                                     |
| -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Name**                   | This is a friendly name for your field.  It can be changed at any time.                                                                                         |
| **Alias**                  | This is how you refer to your model when querying content.  You can change this at any time, however, it will affect any integrations you have built.           |
| **Type**                   | This defines what type of content your field will hold.  See below for more information on the various field types.                                             |
| **Required**               | Indicates that this is a required field.                                                                                                                        |
| **Single/Multiple values** | Fields can be a single value or have multiple values.                                                                                                           |
| **Automatic source**       | Field values can be derived from other sources.  This is discussed in the [automatic fields](https://docs.pokko.io/advanced-features/automatic-fields) section. |

### Field types

| Type                | GraphQL    | Description                                        |
| ------------------- | ---------- | -------------------------------------------------- |
| **Plain text**      | `String`   | Simple plain text field                            |
| **Rich text**       | `JSON`     | Structure text field that allows embedding modules |
| **Date**            | `String`   | Simple date field.  ISO-8601 formatted date        |
| **Numeric**         | `Number`   | Integer or decimal number values                   |
| **Boolean**         | `Boolean`  | Yes/no, true/false                                 |
| **Linked content**  | `PokEntry` | References another entry                           |
| **Modular content** | `PokValue` | Allows for embedding content within the entry      |
| **Media**           | `PokMedia` | Links to an item in the media library              |

### Validation

There are three sources of field validation.  Validation is performed on Publish, not Save.

1. Required
2. Validation
3. Min/max on multiple value fields

## Advanced topics

{% content-ref url="../advanced-features/data-model-inheritance" %}
[data-model-inheritance](https://docs.pokko.io/advanced-features/data-model-inheritance)
{% endcontent-ref %}

{% content-ref url="../advanced-features/automatic-fields" %}
[automatic-fields](https://docs.pokko.io/advanced-features/automatic-fields)
{% endcontent-ref %}

{% content-ref url="../advanced-features/modular-content" %}
[modular-content](https://docs.pokko.io/advanced-features/modular-content)
{% endcontent-ref %}
