Database Schema Generation

Schema Page Empty State
Schema page showing empty state with Generate Schema button

Accessing Schema Section

  1. Navigate to project sidebar

  2. Click "Schema" tab

  3. View schema page

Schema Page Layout

Header Section:

  • Title: "Database Schema"

  • Generate Schema Button: Primary CTA

  • Export Options: SQL, JSON, PDF export buttons

  • Refresh Button: Regenerate schema

Content Area:

  • Schema Tabs: Multiple view options

  • Empty State: Message when no schema exists

Generating Database Schema

Schema Generation Process

  1. Click "Generate Schema" button

  2. System analyzes features, user stories, and data requirements

  3. Real-time generation with progress updates

  4. Generated schema displayed in multiple formats

What Gets Generated

  • Database Tables: Complete table structure with columns

  • Table Relationships: Foreign keys and relationships

  • Indexes: Performance optimization indexes

  • Constraints: Data integrity constraints

  • Functions: Database functions and procedures

  • Triggers: Automated triggers for data consistency

  • Policies: Row Level Security (RLS) policies

Schema Page Tabs

Schema Page Tabs Interface
Schema page showing all six tabs with different view options

Tab 1: Visual Schema

Visual Elements

  • React Flow Diagram: Interactive database relationship diagram

  • Table Nodes: Visual representation of database tables

  • Relationship Lines: Connections between tables

  • Zoom Controls: Pan and zoom functionality

Interactive Features

  • Node Selection: Click tables to view details

  • Relationship Highlighting: Hover over connections

  • Layout Controls: Auto-layout, manual positioning

  • Export Options: Save diagram as image

Tab 2: Tables Overview

Visual Elements

  • Tables List: Comprehensive list of all tables

  • Table Details: Individual table information

  • Column Information: Field details and constraints

Fields Visible

  • Table Name: Database table name

  • Description: Table purpose and description

  • Columns: List of all columns

  • Primary Key: Primary key identification

  • Foreign Keys: Relationship constraints

  • Indexes: Performance optimization indexes

Tab 3: Relationships

Visual Elements

  • Relationship Matrix: Table-to-table connections

  • Constraint Details: Foreign key specifications

  • Cardinality: One-to-one, one-to-many, many-to-many

Fields Visible

  • Source Table: Origin table name

  • Target Table: Destination table name

  • Relationship Type: Connection type

  • Constraint Name: Foreign key name

  • Cascade Rules: Update/delete behavior

Tab 4: SQL Script

Visual Elements

  • SQL Code: Complete database creation script

  • Syntax Highlighting: Code formatting

  • Copy Button: Copy script to clipboard

  • Download Button: Save as .sql file

Fields Visible

  • CREATE TABLE: Table creation statements

  • ALTER TABLE: Constraint additions

  • CREATE INDEX: Index creation

  • Comments: Documentation comments

Tab 5: Functions & Triggers

Visual Elements

  • Function List: Database functions

  • Trigger List: Automated triggers

  • Code Blocks: Function and trigger code

Fields Visible

  • Function Name: Database function names

  • Parameters: Input parameters

  • Return Type: Function return type

  • Trigger Events: When triggers fire

  • Trigger Actions: What triggers do

Tab 6: Policies & Security

Visual Elements

  • RLS Policies: Row Level Security rules

  • Permission Matrix: Access control matrix

  • Security Rules: Data protection rules

Fields Visible

  • Policy Name: Security policy names

  • Table: Protected table

  • Role: User role permissions

  • Condition: Access conditions

  • Action: Allowed operations

Schema CRUD Operations

Create Operations

Add Table

  1. Click "Add Table" button

  2. Fill in table creation form

  3. Define columns and constraints

  4. Click "Save Table"

Add Column

  1. Select existing table

  2. Click "Add Column" button

  3. Define column properties

  4. Click "Save Column"

Add Relationship

  1. Select source and target tables

  2. Click "Add Relationship" button

  3. Define relationship properties

  4. Click "Save Relationship"

Add Index

  1. Select table and columns

  2. Click "Add Index" button

  3. Define index properties

  4. Click "Save Index"

Add Function

  1. Click "Add Function" button

  2. Define function signature

  3. Write function code

  4. Click "Save Function"

Add Trigger

  1. Select target table

  2. Click "Add Trigger" button

  3. Define trigger events and actions

  4. Click "Save Trigger"

Read Operations

View Schema

  • Complete Schema: Browse entire database structure

  • Table Details: View individual table information

  • Relationship Map: Visual relationship representation

  • SQL Script: View generated SQL code

Search Tables

  • Table Search: Find specific tables

  • Column Search: Find tables by column names

  • Relationship Search: Find tables by relationships

  • Advanced Search: Multiple criteria search

Filter by Type

  • Table Types: Filter by table categories

  • Column Types: Filter by column data types

  • Relationship Types: Filter by relationship types

  • Index Types: Filter by index types

Export Schema

  • SQL Export: Export as SQL script

  • JSON Export: Export as JSON data

  • PDF Export: Export as PDF documentation

  • Image Export: Export visual diagram

Update Operations

Edit Table

  1. Click edit icon on table

  2. Modify table properties

  3. Update columns and constraints

  4. Click "Save Changes"

Rename Column

  1. Select column to rename

  2. Click rename option

  3. Enter new column name

  4. Click "Save Changes"

Modify Constraints

  1. Select constraint to modify

  2. Click edit constraint option

  3. Update constraint properties

  4. Click "Save Changes"

Update Indexes

  1. Select index to update

  2. Modify index properties

  3. Update column references

  4. Click "Save Changes"

Edit Functions

  1. Select function to edit

  2. Modify function code

  3. Update parameters or return type

  4. Click "Save Changes"

Modify Triggers

  1. Select trigger to modify

  2. Update trigger events or actions

  3. Modify trigger conditions

  4. Click "Save Changes"

Delete Operations

Remove Table

  1. Click delete icon on table

  2. Confirm deletion in modal

  3. Table and all related data removed

  4. Update dependent relationships

Drop Column

  1. Select column to remove

  2. Click delete column option

  3. Confirm column deletion

  4. Update dependent constraints

Delete Relationship

  1. Select relationship to remove

  2. Click delete relationship option

  3. Confirm relationship deletion

  4. Update constraint references

Drop Index

  1. Select index to remove

  2. Click delete index option

  3. Confirm index deletion

  4. Update performance references

Delete Function

  1. Select function to remove

  2. Click delete function option

  3. Confirm function deletion

  4. Update dependent references

Drop Trigger

  1. Select trigger to remove

  2. Click delete trigger option

  3. Confirm trigger deletion

  4. Update dependent references

Schema Validation

Data Integrity Validation

Constraint Validation

  • Primary Key Constraints: Ensure unique primary keys

  • Foreign Key Constraints: Validate relationship integrity

  • Check Constraints: Validate data value constraints

  • Unique Constraints: Ensure data uniqueness

Relationship Validation

  • Referential Integrity: Validate foreign key relationships

  • Cascade Rules: Validate update/delete cascade behavior

  • Circular Dependencies: Detect circular relationship dependencies

  • Orphaned Records: Detect orphaned records

Performance Validation

Index Optimization

  • Index Coverage: Ensure proper index coverage

  • Index Efficiency: Validate index efficiency

  • Duplicate Indexes: Detect duplicate indexes

  • Missing Indexes: Identify missing performance indexes

Query Optimization

  • Query Performance: Analyze query performance

  • Join Optimization: Optimize table joins

  • Subquery Optimization: Optimize subqueries

  • Index Usage: Analyze index usage patterns

Schema Documentation

Automatic Documentation

Generated Documentation

  • Table Documentation: Automatic table descriptions

  • Column Documentation: Automatic column descriptions

  • Relationship Documentation: Automatic relationship descriptions

  • Function Documentation: Automatic function documentation

Documentation Features

  • JSDoc Comments: Function documentation comments

  • SQL Comments: SQL code documentation

  • Relationship Diagrams: Visual relationship documentation

  • API Documentation: Database API documentation

Manual Documentation

Custom Documentation

  • Table Descriptions: Custom table descriptions

  • Column Descriptions: Custom column descriptions

  • Business Rules: Document business logic

  • Usage Guidelines: Document usage guidelines

Documentation Management

  • Version Control: Track documentation changes

  • Collaboration: Team documentation collaboration

  • Review Process: Documentation review process

  • Approval Workflow: Documentation approval workflow

Database Schema Generation Complete
Complete database schema page showing all generated schema elements

Last updated

Was this helpful?