> ## Documentation Index
> Fetch the complete documentation index at: https://archie.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Fields

> A field is a column on a table. Archie supports nine field types, each with its own validation, defaults, and configuration options.

A field is a column on a table. Each field has a type that controls what data it can store, what validation runs on insert and update, and how it appears in the auto-generated GraphQL and REST APIs.

## Adding a field

Open the table on the **Schema** tab and click **+ Add Field**. Pick a name, choose a type from the dropdown, and configure its options in the right-hand panel. Changes save in real time.

## Field types

<CardGroup cols={3}>
  <Card title="Boolean" icon="toggle-on" href="/features/backend/data-model/fields/boolean">
    True / false flags.
  </Card>

  <Card title="Date" icon="calendar" href="/features/backend/data-model/fields/date">
    Calendar dates and timestamps.
  </Card>

  <Card title="Number" icon="hashtag" href="/features/backend/data-model/fields/number">
    Integers, decimals, and floats.
  </Card>

  <Card title="Text" icon="font" href="/features/backend/data-model/fields/text">
    Strings of any length.
  </Card>

  <Card title="JSONB" icon="brackets-curly" href="/features/backend/data-model/fields/jsonb">
    Structured JSON objects and arrays.
  </Card>

  <Card title="UUID" icon="fingerprint" href="/features/backend/data-model/fields/uuid">
    128-bit unique identifiers.
  </Card>

  <Card title="Relationship" icon="diagram-project" href="/features/backend/data-model/fields/relationship">
    Foreign keys between tables.
  </Card>

  <Card title="Inline enum" icon="list-check" href="/features/backend/data-model/fields/inline-enum">
    A one-off list of allowed values defined on the field.
  </Card>

  <Card title="User-defined" icon="tags" href="/features/backend/data-model/fields/user-defined">
    A reusable Data Type (enum) shared across tables.
  </Card>
</CardGroup>

## Configuration options at a glance

Most field types share a common set of options. The exact set varies by type — see each field type's page for the full list.

| Option            | Available on | What it does                                                                                  |
| ----------------- | ------------ | --------------------------------------------------------------------------------------------- |
| **Name**          | All types    | The system identifier used in the GraphQL and REST APIs.                                      |
| **Description**   | All types    | An internal note describing the field's purpose.                                              |
| **Default Value** | Most types   | The value assigned when a record is created without an explicit value.                        |
| **Mandatory**     | All types    | Enforces a `NOT NULL` constraint — the field cannot be saved empty.                           |
| **Unique**        | Most types   | Enforces a uniqueness constraint across all rows in the table.                                |
| **Type-specific** | Varies       | Number precision, timestamp granularity, JSONB vs. JSON, varchar length, and similar choices. |

## Inline enum vs. user-defined

Both let you constrain a field to a fixed list of values. Choose between them based on reuse:

| Choose this                                                      | When                                                                                                                                                  |
| ---------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Inline enum](/features/backend/data-model/fields/inline-enum)   | The list of values is specific to one field on one table and won't be reused.                                                                         |
| [User-defined](/features/backend/data-model/fields/user-defined) | The list of values needs to stay consistent across multiple fields or tables. Defined once as a [Data Type](/features/backend/data-model/data-types). |

## Permissions

Field-level visibility and write access is controlled per role in [Role-Based Access](/features/backend/app-services/role-based-access), not in the Data Model.

## FAQ

<AccordionGroup>
  <Accordion title="Can I change a field's type after I've added it?">
    Yes, with caveats. Date, Number, and Text values are auto-converted where possible. Switching a field to **Unique** runs a check on the existing data and refuses the change if duplicates exist. Switching a field to **Mandatory** prompts you for a default to backfill existing rows.
  </Accordion>

  <Accordion title="What's the difference between a relationship field and a UUID field?">
    A UUID field stores a free-form 128-bit identifier with no enforcement. A [relationship field](/features/backend/data-model/fields/relationship) stores a foreign key to another table, enforces referential integrity, and creates the inverse query in the GraphQL API automatically.
  </Accordion>

  <Accordion title="Should I use JSON or JSONB?">
    JSONB. It's stored in a binary format that's significantly faster to query and supports indexing. Plain JSON is faster to write but slower to read. See [JSONB](/features/backend/data-model/fields/jsonb).
  </Accordion>

  <Accordion title="How do I make a field optional?">
    Leave **Mandatory** off. Optional fields can be `null` in the database and will be nullable in the generated GraphQL types.
  </Accordion>
</AccordionGroup>
