Fauna Database Schema: Build, iterate and evolve with zero downtime
Develop seamlessly across the schema spectrum, from flexible to full enforcement
Introduction to Fauna Schema
Explore Fauna’s robust Schema features including the Fauna Schema Language, types & enforcement, and zero-downtime migrations in this introductory video.
Define & Manage Schema Alongside Application Code
Leverage Fauna's declarative schema language to define and manage database components seamlessly alongside your application codebase. Articulate complex models with precision, eliminating management overhead and enhancing the clarity and consistency of data structures across the development lifecycle.
“Fauna is the reason we are still in business. There is not enough good stuff I can say about the folks over there.” Read case study
Alice
From Wonderland
Progressively Type and Enforce Schema
Encode sophisticated business logic directly within the database as an element of a schema design using user-defined functions and computed fields. Meanwhile, fully define rich document structures with document types that can progressively enforce schema over time. Together, these features provide the structure and reliability of traditional relational databases with the flexibility of a modern document model.
Evolve Schema with Zero-Downtime Migrations
With Fauna, schema migrations can be scripted and versioned as code, allowing developers to seamlessly align database schema changes with their CI/CD pipelines. This ensures that migrations are predictable, manageable, and integrate smoothly within existing development workflows.
Capabilities
Fauna Schema Language
The Fauna Schema Language (FSL) defines domain models, access controls, and user-defined functions in human-readable files managed as code in your repository of choice. Utilize Fauna’s Schema as Code approach to collaborate on schema design, automate schema changes in your CI/CD pipeline, and fully incorporate database development into your DevOps methodology.
Document Types
Fauna enables in-database schema definition and enforcement, as relational databases do, with the expanded ability to dial in the level of enforcement appropriate to your application. Document Types support both static and dynamic typing, enabling development teams to start with a flexible schema, and introduce stricter type controls as application requirements evolve. This gradual typing system supports a flexible yet controlled approach to data integrity.
Zero-Downtime Migrations
Safely deploy schema changes without service interruptions. Fauna's zero-downtime migration system applies schema definitions transactionally, and prohibits schema changes that conflict with the underlying data. Expressed in FSL, zero downtime migrations can be deployed successively to your development, test, staging, and production environments, assuring database changes are reviewed and well tested before deployment to production.
Check Constraints
Check constraints ensure that data written to a database adheres to specific business logic (such as ensuring a bank account never falls below zero), especially valuable for applications that require strict data validation to maintain data integrity and without having to encode these checks in your application.
Computed Fields
Computed fields enable you to accurately define your true data model in the database, as they express the ‘has-a’, ‘has-many’ associations which historically had to be defined in mapping layers running outside of databases. Define cross-collection joins and subqueries as an element of your schema design, so you can dynamically generate data, and object models in real-time.
Schema Flexibility
Start with a schemaless design for rapid prototyping and iterate towards a more structured schema as your application matures. This flexible approach reduces initial barriers and adapts to changing development needs.
Build Applications with Confidence
Evolve Database Schema
Fauna schema allows you to start schemaless and gradually enforce schema rules as your application evolves. For instance, a retail application may begin with a flexible schema to quickly bring a new feature to market or easily import new datasets, but can enforce product and customer data structures to ensure data integrity and improve query performance over time.
Centralize Domain Model
Uniquely express your entire domain model within the database, making it the single source of truth for your application. Instead of having your domain defined across disparate code blocks, ORM configurations, and database schemas, Fauna schema allows you to centralize and manage your domain model seamlessly. This centralization ensures consistency, reduces errors, and streamlines the development process, providing a clear and cohesive structure for your application.
Ensure Data Consistency
Leverage document type enforcement to maintain data consistency across your application. For example, in a healthcare application, you can introduce schema rules that ensure patient records contain required fields like patient ID, diagnosis, and treatment plans, reducing the risk of data errors and ensuring compliance with healthcare regulations.
Implement Business Logic Natively
Fauna's user-defined functions, check constraints, and computed fields allows teams to implement business logic at the database level. In a finance application, for example, you can create constraints to ensure that transactions are only processed if account balances meet certain criteria, preventing overdrafts and maintaining financial integrity.
Optimize Query Performance
Enforcing schema rules in Fauna can optimize query performance by ensuring that data is structured predictably. In an e-commerce platform, enforcing schemas for product categories, prices, and inventory levels can streamline queries for faster search results and better user experience.
From Document to
Document-Relational Databases
Explore the history and benefits of document models, the challenges they pose, and how Fauna's document-relational database overcomes these challenges.
“Fauna's schema capabilities unlock powerful optionality for evolving and enforcing our database schema over time. These features enable us to dial-in and dial-out schema as our applications evolve and adapt to changing business requirements without compromising data integrity or business operations.”
Cameron Bell, Head of Software, Systems, & Data
Get started building with Fauna
Explore resources that can help get you up and running in minutes.
Multi-tenant SaaS Sample App
Learn how to build a multi-tenant, multi-region SaaS app without ops using Fauna and AWS
BUILD THE SAMPLE APP
New to Fauna Query Language?
This guide can help you get started with FQL in under 10 minutes.
READ MORE
Workshops
Learn how to build complete applications using technology like AWS, Cloudflare, and more.
EXPLORE THE WORKSHOPS
FAQs
Have other questions? Feel free to contact us, or browse our documentation.
Get started building with Fauna
Explore resources that can help get you up and running in minutes.
Schema Guide
Get started building schema in Fauna with this quick-start guide that walks you through progressive enforcement of schema.
START THE TUTORIAL
New to Fauna Query Language?
This guide can help you get started with FQL in under 10 minutes.
READ MORE
Workshops
Learn how to build complete applications using technology like AWS, Cloudflare, and more.
EXPLORE THE WORKSHOPS
FAQs
Have other questions? Feel free to contact us, or browse our documentation.
Ready to get started?
Launch a new app, modernize an existing app, and scale seamlessly across regions with Fauna.
Ready to get started? Launch a new app, modernize an existing app, and scale seamlessly across regions with Fauna.
Ready to get started? Launch a new app, modernize an existing app, and scale seamlessly across regions with Fauna.