Skip to main content
Backdrift automatically designs your database schema from natural language. Describe your data, and we handle the rest.

Database Options

Backdrift supports two database backends:
OptionBest ForFeatures
DynamoDB (default)Simple apps, high scaleNoSQL, auto-scaling, pay-per-request
RDS PostgreSQLComplex queries, joinsRelational, SQL, foreign key constraints
To request PostgreSQL, mention it in your prompt:
"A CRM with users, contacts, and deals. Use PostgreSQL for complex reporting queries."

Entities

Entities are your data models. Each entity becomes a database table with automatic CRUD endpoints.

Defining Entities

"Tasks have a title, description, due date, priority, and status."
This generates:
interface Task {
  id: string;           // Auto-generated primary key
  title: string;
  description?: string;
  due_date?: string;    // ISO datetime
  priority: 'low' | 'medium' | 'high';
  status: 'pending' | 'active' | 'done';
  created_at: string;   // Auto-managed
  updated_at: string;   // Auto-managed
}

Field Types

TypeDescriptionExample
stringText datanames, descriptions
numberFloating pointprices, scores
integerWhole numberscounts, ages
booleanTrue/falseis_active, is_verified
datetimeISO timestampdue_date, created_at
dateDate onlybirth_date
enumFixed optionsstatus, priority
jsonArbitrary JSONmetadata, settings

Field Constraints

Required vs Optional

"Tasks have a required title and optional description."

Unique Fields

"Users have a unique email address."

Default Values

"Task status defaults to 'pending'."

Enums

"Priority can be low, medium, or high."

Relationships

One-to-Many

"Tasks belong to projects. A project has many tasks."
This creates:
  • project_id foreign key on Task
  • Index for efficient queries
  • Cascade delete options

Many-to-Many

"Tasks can have multiple tags. Tags can be on multiple tasks."
This creates a join table automatically.

Self-Referential

"Tasks can have subtasks."
Creates a parent_task_id field on Task.

Automatic Fields

Backdrift adds useful fields automatically:
FieldDescription
idUUID primary key
created_atWhen record was created
updated_atWhen record was last modified
org_idTenant ID (if multi-tenant)

Indexes

Backdrift creates indexes for:
  • Primary keys (id)
  • Foreign keys (project_id)
  • Tenant keys (org_id)
  • Frequently queried fields

Query Optimization

"Users often search tasks by status and due date."
This hints Backdrift to create a composite index on (status, due_date).

Multi-Tenant Data

In multi-tenant mode, every entity gets:
interface Task {
  id: string;
  org_id: string;  // Auto-injected tenant ID
  // ... other fields
}
All queries are automatically filtered by org_id.

PII Detection

Backdrift detects Personally Identifiable Information:
Field PatternDetection
emailEmail PII
phonePhone PII
ssnSSN PII (Critical)
addressAddress PII
When PII is detected, we recommend:
  • Encryption at rest
  • Access logging
  • Data retention policies

Example: E-commerce

"An e-commerce platform with:
- Products with name, description, price, and category
- Categories with name and description
- Orders with status, total, and customer
- Order items linking orders to products with quantity"
Generates:
┌─────────────┐     ┌─────────────┐
│  Category   │     │   Product   │
├─────────────┤     ├─────────────┤
│ id          │←────│ category_id │
│ name        │     │ name        │
│ description │     │ description │
└─────────────┘     │ price       │
                    └─────────────┘

┌─────────────┐     ┌─────────────┐
│   Order     │     │ Order Item  │
├─────────────┤     ├─────────────┤
│ id          │←────│ order_id    │
│ customer_id │     │ product_id  │─→
│ status      │     │ quantity    │
│ total       │     │ unit_price  │
└─────────────┘     └─────────────┘

Scheduled Jobs

Learn how to run background tasks on a schedule.