Skip to main content
Formbricks uses PostgreSQL as its primary database and Prisma as the Object-Relational Mapping (ORM) tool. The database schema is designed to support multi-tenancy, survey management, and response collection while maintaining data isolation between organizations.

Entity Relationship Diagram

The following diagram shows the core entities and their relationships in the Formbricks database:

Core Models

Organization & Workspace Management

  1. Organization
    • Top-level entity for multi-tenancy
    • Contains multiple Workspaces and team members
    • Manages billing and whitelabel settings
  2. Workspace
    • Main grouping mechanism for surveys and related configuration
    • Belongs to a single organization
    • Controls branding and display settings
  3. WorkspaceTeam
    • Maps teams to Workspaces
    • Controls Workspace-level access permissions
    • Enables scoped collaboration across teams

Survey Management

  1. Survey
    • Central model for questionnaires
    • Configurable with multiple questions and display rules
    • Supports multiple languages and targeting filters
  2. Response
    • Records user answers to surveys
    • Links to contact information when available
    • Supports tagging for analysis
  3. ActionClass
    • Defines triggering points for surveys
    • Can be code-based or no-code configurations
    • Links surveys to specific user actions

User Management

  1. User
    • Represents system users (admins/team members)
    • Manages authentication and preferences
    • Can belong to multiple organizations
  2. Contact
    • Represents survey respondents
    • Stores attributes for targeting
    • Tracks survey displays and responses
  3. Team
    • Groups users within organizations
    • Controls Workspace access permissions
    • Facilitates collaborative survey management

Data Isolation

The database schema ensures proper data isolation through:
  1. Organization-level isolation
    • Each organization has its own Workspaces
    • Users can belong to multiple organizations
    • Resources are scoped to organizations
  2. Workspace-level isolation
    • Independent surveys, contacts, action classes, and integrations
    • Isolated API key Workspace assignments
    • Workspace-specific configuration and styling defaults
  3. Team-based access isolation
    • Teams are linked to Workspaces through WorkspaceTeam
    • Permissions are scoped per Workspace
    • Access can be delegated without exposing all organization resources

Schema Management

The database schema is managed through Prisma, which provides:
  • Type-safe database client
  • Automatic migration generation
  • Schema versioning
  • Data validation
  • Query optimization
For detailed information about specific models and their properties, refer to the schema.prisma file in the repository.

PostgreSQL Database Tables

Formbricks stores all data in PostgreSQL tables. Here’s a comprehensive list of all database tables and their purposes:

Schema Reference

For detailed information about the database schema, including:
  • Complete field definitions
  • Relationships between tables
  • Enums and custom types
  • Field constraints and indices
  • JSON field structures
Please refer to the Prisma schema file in our GitHub repository. The schema.prisma file contains extensive documentation comments for each model, making it the authoritative reference for the database structure.