# Building Models

## Understanding requirements

Let us assume we have a student data with given Schema that we need to store in database :&#x20;

```javascript
{
    "id":{
        "type":"objectId",
        "required":true,
    },
    "name":{
       "type":"string",
       "required":true,
    },
    "age":{
        "type":"number",
        "required":true,
    },
    "subjects":{
        "type":"string[]",
        "required":true,
    },
    "address":{
        "city":{
            "type":"string",
            "required":true,
        },
        "state":{
            "type":"string",
            "required":true,
        }
    }

}
```

To build the model with given schema above follow these steps :&#x20;

1. Navigate to Models screen from **Application Layer -> Models**.
2. Click on **Create Model** button and configure models name, description and model type as per your preference. For instance, if you would like to build the Student's DB model above, you can select **Database Collection** model type. You can check other [<mark style="color:blue;">**model types here**</mark>](https://docs.cosmocloud.io/resources/models).
3. After model is created navigate to **Schema** tab on top of model details page.
4. You can now start building your model's schema.

Models schema for above requirements would appear something like this :&#x20;

<figure><img src="https://392607133-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZCdm9aJ8vkvDIIbg04AL%2Fuploads%2F7tg8c5a5c5e5ac1QBrfx%2Fimage.png?alt=media&#x26;token=2b0f9c92-38ab-434e-8ab8-27fa97a2e0c4" alt=""><figcaption><p>model schema</p></figcaption></figure>

## Supported data types in schema builder

* **ObjectID**: An ObjectID is a unique 12-byte identifier typically represented as a hexadecimal string. These are used to uniquely identify documents in a collection. This can also be used when making references to other IDs of other collections (for ex. a record in *Orders* collection could have a `userId: ObjectId` )
* **Boolean**: Boolean is often used to express binary decisions or states i.e. True or False.
* **String**: A string data type represents text. It can contain letters, numbers, symbols, and spaces. Strings are used to store textual information.
* **Integer**: An integer data type represents whole numbers, both positive and negative, *without floating points*.
* **Float**: A float data type represents decimal numbers. Unlike integers, floats can have fractional parts. They are used for calculations involving real numbers.
* **Nested**: The "Nested" type typically refers to nested or embedded structures within a data model. Unlike Dict it has a defined schema.
* **Array**: An array is a collection of elements of the same data type, ordered by an index. These are used to store multiple values in a single key.
* **Dict**: A dictionary is a collection of key-value pairs. This is different from Nested, as a Dict is a open ended object and can accept any sub fields, whereas Nested has a defined schema.

{% hint style="info" %}
Some model types have restrictions of types of properties you can use. For for more information, [<mark style="color:blue;">**please check here**</mark>](https://docs.cosmocloud.io/resources/models).
{% endhint %}
