• Start

Overview

Schema management

How to shape data in SurrealDB: tables, fields, indexes, events, tenancy, and related patterns.

Schema management is where you describe what lives in the database: tables and fields, indexes, events, optional files and buckets, and the namespace / database layout for multi-tenant setups.

What makes SurrealDB convenient is that schema management can be almost entirely dispensed with at the outset, because standard CRUD (Create, Read, Update, Delete) operations do not require a schema to be defined at the outset. This allows you to experiment at your leisure until it is time to firm up your database's expected record and data types, at which point schema definition comes to the fore.

Schema is not all about defining data, however. For example, statements like DEFINE EVENT set up effects that take place after a statement is executed.

The learn pages here explain how and why to use these pieces together. For exact statement grammar, defaults, and edge cases, use the SurrealQL reference (DEFINE and related pages).

If you are new to SurrealDB, it helps to read tables and fields first, then indexes and events when you need behaviour beyond simple storage.

Was this page helpful?