> For the complete documentation index, see [llms.txt](https://docs.novel.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.novel.dev/guides/knowledge-base/database/creating-a-table.md).

# Creating a Table

{% embed url="<https://knexjs.org/guide/schema-builder.html>" %}

## Best Practices

* Name your table in plural form.
* Be careful of your indices and primary keys. Maybe a composite primary key is more useful.
* There is no need to add a maximum length to strings.
* Make use of `.references('table_name.foreign_key')` when defining relationships.
* Make use of timestamps for boolean fields.
* Make sure you add references to organization ID or account ID where needed.
* Avoid using UUID v4s for your Primary Keys. Consider UUID v1/v7, ULID, or normal Big Int.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.novel.dev/guides/knowledge-base/database/creating-a-table.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
