---
title: Fields
slug: v4-7/document-model/fields
docTags: 
createdAt: 2024-02-26T18:13:33.442Z
---

A document consists of sets of fields that self-describe the data it encodes. Each set signifies a single pair of two associated elements:

- The name identifying the field.&#x20;
- The value that holds the data.&#x20;

:::CodeblockTabs
Ditto Document

```json
{
  _id: "123",
  field1: "abc",
  field2: 1,
  field3: {
    sub_field1: "xyz",
    sub_field2: 2
  }
}
```
:::

# Names

Similar to most document-oriented databases, you can only use `strings` to encode field names in documents.&#x20;

For complete naming rules, see [IDs, Paths, Strings, and Keywords](docId\:sf7KAss14pBlQkUOFJxju).

:::hint{type="warning"}
If you attempt to insert a type other than a `string` for a field property, as demonstrated in the following snippet, you will receive an error message.
:::

:::CodeblockTabs
&#x20;

```none
{
    1: "numeric_fields_are_invalid_here",
    "this_part": "numeric_fields_are_valid_here"
}
```
:::

# Values

Field values can be encoded using various *data types*, including scalar type, providing flexibility in representing a wide range of information.

Following are the data types you can use to represent information in a Ditto document:

- `REGISTER`
- `MAP`
- `ATTACHMENT`

Each data type contains two distinct components: a merge behavior and a scalar value to store. (See [Data-Handling Essentials](docId\:W4y7AvICPmj0AOwXmDvZ2))

# Hierarchies

In the following structure, field properties are logically grouped to provide details about a specific car.&#x20;

This structure includes an embedded object encapsulating both the GPS latitude and longitude coordinates, as well as the physical address where the car is located:

::Image[]{src="https://api.archbee.com/api/optimize/qoRkNxW5fJ81r_NqVpc8C/nE76-8SxgOLCjFhcWaVqc_embedded-object.png" size="72" width="2259" height="1265" position="flex-start" showCaption="false"}

