Directus provides a flexible and powerful data modeling system that allows you to define and manage your database schema through an intuitive interface or API. The data model supports any SQL database and automatically mirrors your database schema.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/directus/directus/llms.txt
Use this file to discover all available pages before exploring further.
Collections
Collections are the foundation of your data model in Directus. Each collection represents a table in your database and can be managed dynamically.Creating Collections
Collections can be created through the App, API, or directly in your database:System Collections
Directus includes built-in system collections for managing:- directus_users - User accounts and authentication
- directus_files - File metadata and asset management
- directus_folders - File organization hierarchy
- directus_roles - Access control roles
- directus_permissions - Granular permission rules
- directus_activity - Action logs and revisions
- directus_flows - Automation workflows
- directus_operations - Flow operation steps
Fields
Fields define the columns in your collections with rich metadata and validation options.Field Types
Directus supports all standard database types:- String - Text data (VARCHAR, TEXT)
- Integer - Whole numbers
- Float - Decimal numbers
- Boolean - True/false values
- Date/Time - Timestamps and dates
- JSON - Structured data objects
- UUID - Unique identifiers
- Binary - File and blob data
Creating Fields
Field Metadata
Each field can include rich metadata for the App interface:- Interface - Input component (text-input, select-dropdown, wysiwyg, etc.)
- Display - Read-only display template
- Options - Interface-specific configuration
- Validation - Rules and constraints
- Conditions - Show/hide based on other field values
- Width - Layout width (half, full, fill)
Relationships
Directus supports all standard relational database patterns:One-to-Many (O2M)
A single parent record relates to multiple child records.Many-to-One (M2O)
The inverse of O2M - multiple records relate to a single parent.Many-to-Many (M2M)
Records from both collections relate to multiple records in the other through a junction table.Many-to-Any (M2A)
Relate to items across multiple collections - useful for polymorphic relationships.Schema Migration
Changes to your data model are automatically synced to your database:- Create - New collections and fields are created in the database
- Update - Field types and constraints are altered
- Delete - Collections and fields can be removed (with cascade options)
Validation & Constraints
Field Validation
Add validation rules to ensure data quality:Database Constraints
- Primary Keys - Unique row identifiers
- Foreign Keys - Referential integrity
- Unique Constraints - Prevent duplicates
- Not Null - Required fields
- Default Values - Auto-populated values
- Check Constraints - Custom validation rules
Aliases & Virtual Fields
Create computed fields that don’t exist in the database:Best Practices
Use Appropriate Field Types
Use Appropriate Field Types
Choose the most specific type for your data - use
integer instead of string for numbers, boolean instead of integers for flags, etc.Define Clear Relationships
Define Clear Relationships
Model relationships explicitly rather than storing IDs as strings. This enables relational queries and data integrity.
Leverage Metadata
Leverage Metadata
Use field metadata to create better user experiences - add helpful notes, validation rules, and appropriate interfaces.
Plan for Localization
Plan for Localization
If you need multilingual content, use the translations interface and proper relationship structures.