Is a Sanity Dataset like a database or a table?

63 replies
Last updated: Apr 18, 2020
Can anyone explain me if a Dataset is like a database or like a table?
AI Update

Great question! A dataset is more like a database than a table.

In Sanity's architecture, a dataset is a named, isolated collection of all your JSON documents and assets within a project. Think of it as a complete, self-contained database environment where all your different content types (which you might think of as "tables") live together.

Here's the breakdown:

  • Project = Your overall Sanity account/application
  • Dataset = A complete database (like production, development, or staging)
  • Document types (defined in your schema) = More like tables within that database

Each dataset is completely isolated from others - you can't directly query data from one dataset while connected to another. This isolation makes datasets perfect for creating separate environments. For example, you might have:

  • A production dataset with your live content
  • A development dataset where developers can test schema changes without affecting live content
  • A staging dataset for validating changes before going live

The cool part is that datasets are schemaless, meaning different datasets can have completely different content structures if needed. You can configure your Studio to work with different datasets using environment variables, so running sanity start locally might use your development dataset while sanity deploy uses production.

Free plans include 2 datasets, and paid plans offer more depending on your needs. If you're on an Enterprise plan, you also get access to Advanced Dataset Management features like cloud cloning and hot swapping, which make managing multiple datasets even easier.

Show original thread
63 replies
It’s like a database, that is a collection of documents of different types that can contain references to each other.
Oh, so it’s a NoSQL database?
May I know on which cloud are your services running?
Exactly! But with indexed and joinable relationships 🙂
It runs on Google Cloud Platform
Cool!
It's not firebase/firestore, but our own custom backend built with mature and “boring” database technologies.
I want to use this tool in my Development Agencies for those small projects that don’t require custom backend solutions, how many people are actively working in this? I’m comparing alternatives to Contentful
Working at Sanity the company, or with Sanity the solution?
Sanity directly in further develop this tool
We launched publicly in 2017, are currently 25 at the company, and rapidly growing. You can see some of our bigger clients here: https://www.sanity.io/solutions – if you need more references,
user H
is ready to give'em to you.
But I'm confident that you can safely use Sanity for those project. You get a lot of customization too.
What happens when I want to migrate to our own database?
If you want to migrate your content, it's
sanity dataset export <datasetnam>
in the CLI and you get all your documents including image and file binaries neatly packaged in a tar.gz file containing ndjson files
That sounds great
the whole point is that it should be easy to use your content where you need it, which implies it easy to migrate too. The only lock-in is the developer experience, whatever customization you need that relies on real-time features (that we are mostly alone in offering in the CMS space, as far as I know)
just to give you an idea of a dataset + export, here's the endpoint which streams your whole dataset (just public docs if not authenticated)
curl <https://cmghl2o6.api.sanity.io/v1/data/export/production>

Nice
Is there a good example about authentication ?
as you can see, there's some assets documents there too containing the metadata for images you have uploaded
If you use the JS client is mostly:
client.config({ token: process.env.READ_TOKEN })
or

client.config({ withCredentials: true})
if you want to do authed requests on behalf of logged-in users client-side
But how does the user “log in” or get the token?
You invite them to the project and we set a cookie with the auth token on it that's sent with requests against our APIs
the CMS/Sanity Studio is a React SPA which connects to these APIs
I mean, how does app user login or get the token? not the developer
Or all the web/app instances will use the same access token?
So, if you have invited an editor to the project, and they log in to the studio, they are authenticated on all API calls to that project in that browser.
Tokens you can create in settings and add to server environments etc
If you need SSO or third party login, there is that as well, but on the enterprise plan https://www.sanity.io/docs/third-party-login
No no, I mean my app user, in other words, when I publish the app to the stores or when I deploy the web, users will call the API, how will those users get the token?
As far as I understand I get a GraphQL API for my datasets right?
Aha, gotcha. Generally, you'll need to one of two things:
• Have the app request a proxy layer that has got a token with Read and/or Write rights
• Use our custom access control and SSO features in your authentication layer to set the session token in your app
Generally, most people use a public dataset, which means that you can request published documents without authentication (while drafts will still only be visible for logged-in users)
You can deploy a GraphQL API (or several actually using the tag-feature), there is also a dedicated query language for JSON documents called GROQ https://www.sanity.io/docs/how-queries-work
Alright, if I want to have a custom domain name will I have to do the proxy layer too? Or Sanity provides that functionality?
We offer custom domain name (CNAME) on enterprise
But that would still have the sanity.io domain right?
nope, then instead of doing requests to
https://<projectId>.<http://api.sanity.io/v1/data/query/|api.sanity.io/v1/data/query/><dataset>?query=*
it would be

<https://api.yourdomain.com/v1/data/query/><dataset>?query=*
(or another subdomain)
What’s the starting price for Enterprise
I'm not actually sure atm 😄 But
user H
will probably DM you when he's up and about 👍
Nevermind, already checked the Advanced plan, which means that the enterprise is above 199/month
Correct
One last question
If I want to offer this option to my agency customers, am I able to resell the service as a managed service by my agency at my own fees?
That is a conversation you'll also have to have with Jacob (Head of Business Development) 🙂
Alright
Thanks
user Y
I guess I’ll get contacted by Jacob right?
Oh, almost forgot, am I able to deploy the Admin dashboard to a custom hosting?
You are! It’s a react SPA so you can even deploy more of them with different configs on the same project :)
So that my customers can edit content from that app deployed on custom hosting?
Yup
I’ll explore this product further, so far it seems promising, my only concern would be that the UI doesn’t seem to bee as elegant as the other solutions (GraphCMS, Contentful, DatoCMS), but I believe that’s something that can be improved very quickly
Aight! fwiw There's an UI overhaul on the roadmap. And you'll quickly notice that you'll be able to express far more advanced content models with it compared to those others. Feel free to ask people here for their experiences compared to other platform in help as well!
Nice to know!, if I may suggest, you should have a public roadmap if you don’t have one, and also, take in count that some admin dashboards require very custom setups, it would be nice if you come up with a trendy micro-frontend compatible update so that we can re-use things already built in angular or Vue to extend the project
Yeah, we have consciously chosen not to have a public roadmap, because we need to be able to shift course to do new features properly. That being said, you can get a sense of what's going on if you lurk in our PRs and branches here: https://github.com/sanity-io/sanity
I believe we'll stick with giving you customization of Sanity Studio with React for now, but there is libraries like
https://github.com/danielroe/vue-sanity and you'll also have access to the full mutation and patch API if you want to make your own forms to the backend.
The studio contains a lot of APIs and extension points to do custom stuff, from having your own asset selectors to custom publish actions for documents and so on
And if you have specific questions, we're always willing to talk btw
Thanks!
I gotta sleep (2am local time), but before I go, does sanity support localization?
Not just for the content, but for the studio too
Full i18n support for the studio is also on the roadmap, that being said, there isn't a lot of UI that isn't already defined by your schemas.
Nice
Hey Jonathan! Sent you PM now. Happy to help!

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?