Understand schemas
Decide what each record contains before you save it.
A schema names the fields in a table and the values each field accepts.
| id | name | price_cents |
|---|---|---|
| p001 | Travel mug | 1990 |
| p002 | Desk lamp | 3500 |
Choose how to create it
Use the console
Add fields and choose their types in the visual editor.
Write a schema file
Save the definition as a TOML text file and keep it with your code.
Use SQL
Create a table with a supported CREATE TABLE statement.
- Name the tableChoose its namespace and a clear table name.
- Choose the primary keyDecide which field uniquely identifies each record.
- Define the fieldsChoose names, types and required values.
- Save and inspect the definitionConfirm the table exists before loading data.
Start with three decisions
| Decide | Example | Meaning |
|---|---|---|
| Where the table belongs | shop.customers | shop groups related tables; customers names this table. |
| How to identify a record | id | The primary key is the field that uniquely identifies each customer. |
| What to store | id, email, signup_ms | Each column has a name and a type, such as text or a whole number. |
See this table as a schema file
Save the following as manifest.toml. TOML is a text format for configuration.
namespace = "shop"
table = "customers"
primary_key = ["id"]
[[columns]]
name = "id"
ty = "str"
required = true
[[columns]]
name = "email"
ty = "str"
[[columns]]
name = "signup_ms"
ty = "u64"straccepts text.u64accepts non-negative whole numbers.required = truemeans the record must include that field.- Each
[[columns]]block adds one field to the table.
Choose suitable field types
Start with text, numbers and yes/no values. Use a more specific type when you need validation for dates, identifiers or other structured values.
- Names and email addresses:
str. - Whole numbers:
i64oru64, depending on whether negatives are allowed. - Yes/no values:
bool. - Money:
decimal, or integer minor units such as cents. Avoid floating-point rounding.
The type reference lists the accepted formats and additional settings.
Save the definition
In the console, review and save the table definition. If you use a TOML file, submit it through the schema registration API.
After the request succeeds, check that the table appears before adding records. A schema defines the table; it does not add customer data.
Add rules when you need them
| Need | Add |
|---|---|
| Find rows by a frequently searched field | An index. |
| Follow links between records | A relation. |
| Require a referenced record to exist | A foreign key. |
| Reject values that break a rule | A check constraint. |
Keep search indexes in mind
Saving a row does not automatically create its vector embedding or full-text index. Those use separate operations, linked to the record by its ID.
See vector schemas or full-text indexing when you add those search methods.
Next step
Create your first schema, or look up a specific setting in the schema reference.