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

# schema.ts

> Declare your tables and indexes in the schema.ts file.

`bijection/schema.ts` allows you to declare your [**tables**](/database/schemas)
and their [**indexes**](/database/reading-data/indexes/indexes). Bijection derives your
document types from it, and validates every insert and update in the declared
tables — unless you turn that off with
[`schemaValidation: false`](/database/schemas#schemavalidation-boolean).
Documents in tables the schema doesn’t list are never validated.

The file is optional: without it, no schema is enforced on your documents. If
you don’t have a schema yet, you can
[generate one from the console](/dashboard/deployments/schema#viewing-the-schema-file).

```ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { defineSchema, defineTable } from "bijection/server";
import { v } from "bijection/values";

export default defineSchema({
  messages: defineTable({
    body: v.string(),
    author: v.id("users"),
  }).index("by_author", ["author"]),
});
```

## Learn More

* [Schemas](/database/schemas)
* [Indexes](/database/reading-data/indexes/indexes)
* [Schema in the Console](/dashboard/deployments/schema)
