Module 02
Page 01
1 min

Schemas

How schemas work in Sanity with custom data


What's a schema?

A schema describes the type of content we want to create in Sanity. It's comprised of various fields and content types, which Sanity will build the user interface for.

For example, if I wanted to make a schema for a Dog, it might look like this:

A Dog Diagram with the fields of Name, Breed, and Age.

It might be easy to have Name and Breed be Strings(normal text), and the Age to be a number. But let's take a closer look at Breeds;

Multiple schemas

There are various breeds of dogs, and we might not want to have the problem of inserting a breed that doesn't exist. Maybe we only have three breeds, and don't want any other options.

  • Shih Tzus
  • Golden Retrievers
  • Bulldogs

So our we might might change our schema and have it look like this:

Now, the more breeds we want to add to the schema, the more complicated it gets. Luckily, now we'll see the power of the schema - we can create another schema specifically for breeds.

Now, we can make many different breeds based on the Breed schema, and use those breeds in the Dog schema!

An easy way to think about Schemas is a custom data type. We can make more data relating to one type and use it in other types and vice versa. Next, we'll turn this into code, as we learn about Documents and Objects.

Ritesh Kanchi © 2025