Create database schemas quickly for different AI agent actions using natural language. Use GibsonAI's natural language database management to rapidly set up data structures for various agent workflows and use cases.

How it works

GibsonAI enables rapid database schema creation using natural language descriptions. Instead of manually designing database schemas, you can describe what you need in plain English and have GibsonAI generate the appropriate database structure for your agent workflows.

Key Features

Natural Language Schema Creation

  • Instant Schema Generation: Create database schemas from natural language descriptions
  • Table Definition: Define tables with relationships using simple prompts
  • Data Type Selection: Automatically choose appropriate data types
  • Index Creation: Generate indexes for optimal performance

Rapid Development

  • Quick Prototyping: Rapidly prototype database schemas for different use cases
  • Iterative Design: Easily modify schemas as requirements evolve
  • Immediate APIs: Get REST APIs instantly when schema is created
  • Model Generation: Automatically generate Python models

Flexible Schema Management

  • Multiple Projects: Create different database schemas for different agent workflows
  • Schema Evolution: Easily modify existing schemas as needs change
  • Testing Environments: Create test schemas for validation
  • Production Deployment: Deploy schemas to production when ready

Use Cases

Agent Workflow Development

Perfect for:

  • Creating database schemas for new agent workflows
  • Prototyping data structures for different use cases
  • Testing schema designs with sample data
  • Validating data models before production

Rapid Prototyping

Enable:

  • Quick database setup for proof-of-concept projects
  • Testing different data models and relationships
  • Validating agent data requirements
  • Iterating on schema designs

Multi-Agent Systems

Support:

  • Creating specialized databases for different agent types
  • Isolating data for different agent workflows
  • Managing complex multi-agent data relationships
  • Coordinating data access across agent systems

Implementation Examples

Creating Schema for Customer Service Agent

# Using Gibson CLI to create customer service database schema
# Create customer service tables with natural language
# gibson modify customers "Create customers table with id, name, email, phone, account_status, created_at"
# gibson modify support_tickets "Create support_tickets table with id, customer_id, issue_type, description, priority, status, created_at, resolved_at"
# gibson modify agent_responses "Create agent_responses table with id, ticket_id, agent_id, response_text, timestamp, satisfaction_score"
# gibson modify escalations "Create escalations table with id, ticket_id, escalated_to, reason, escalated_at"

# Generate models and deploy
# gibson code models
# gibson merge

Creating Schema for E-commerce Agent

# Create e-commerce database schema quickly
# gibson modify products "Create products table with id, name, description, price, category, stock_quantity, active"
# gibson modify orders "Create orders table with id, customer_id, total_amount, status, payment_method, created_at"
# gibson modify order_items "Create order_items table with id, order_id, product_id, quantity, unit_price"
# gibson modify shopping_carts "Create shopping_carts table with id, customer_id, product_id, quantity, added_at"
# gibson modify reviews "Create reviews table with id, product_id, customer_id, rating, comment, created_at"

# Generate models and deploy
# gibson code models
# gibson merge

Creating Schema for Analytics Agent

# Create analytics database schema
# gibson modify user_events "Create user_events table with id, user_id, event_type, event_data, timestamp, session_id"
# gibson modify page_views "Create page_views table with id, user_id, page_url, referrer, timestamp, duration"
# gibson modify conversions "Create conversions table with id, user_id, conversion_type, value, timestamp"
# gibson modify user_segments "Create user_segments table with id, user_id, segment_name, segment_value, calculated_at"

# Generate models and deploy
# gibson code models
# gibson merge

Quick Schema Creation Framework

import subprocess
import json

class QuickSchemaCreator:
    def __init__(self):
        self.schemas = {}

    def create_schema_for_action(self, action_name, table_descriptions):
        """Create database schema for specific agent action"""
        print(f"Creating schema for action: {action_name}")

        # Store schema description
        self.schemas[action_name] = {
            "tables": table_descriptions,
            "created_at": datetime.now().isoformat()
        }

        # Generate Gibson CLI commands
        for table_name, description in table_descriptions.items():
            command = f'gibson modify {table_name} "{description}"'
            print(f"Executing: {command}")

            # Note: In real implementation, you would execute the command
            # result = subprocess.run(command, shell=True, capture_output=True, text=True)
            # if result.returncode != 0:
            #     print(f"Error creating table {table_name}: {result.stderr}")
            #     return False

        # Generate models
        print("Generating models...")
        # subprocess.run("gibson code models", shell=True)

        # Deploy schema
        print("Deploying schema...")
        # subprocess.run("gibson merge", shell=True)

        print(f"Schema for {action_name} created successfully!")
        return True

    def create_customer_service_schema(self):
        """Create schema for customer service agent"""
        table_descriptions = {
            "customers": "Create customers table with id, name, email, phone, account_status, created_at",
            "support_tickets": "Create support_tickets table with id, customer_id, issue_type, description, priority, status, created_at, resolved_at",
            "agent_responses": "Create agent_responses table with id, ticket_id, agent_id, response_text, timestamp, satisfaction_score",
            "escalations": "Create escalations table with id, ticket_id, escalated_to, reason, escalated_at"
        }

        return self.create_schema_for_action("customer_service", table_descriptions)

    def create_ecommerce_schema(self):
        """Create schema for e-commerce agent"""
        table_descriptions = {
            "products": "Create products table with id, name, description, price, category, stock_quantity, active",
            "orders": "Create orders table with id, customer_id, total_amount, status, payment_method, created_at",
            "order_items": "Create order_items table with id, order_id, product_id, quantity, unit_price",
            "shopping_carts": "Create shopping_carts table with id, customer_id, product_id, quantity, added_at",
            "reviews": "Create reviews table with id, product_id, customer_id, rating, comment, created_at"
        }

        return self.create_schema_for_action("ecommerce", table_descriptions)

    def create_analytics_schema(self):
        """Create schema for analytics agent"""
        table_descriptions = {
            "user_events": "Create user_events table with id, user_id, event_type, event_data, timestamp, session_id",
            "page_views": "Create page_views table with id, user_id, page_url, referrer, timestamp, duration",
            "conversions": "Create conversions table with id, user_id, conversion_type, value, timestamp",
            "user_segments": "Create user_segments table with id, user_id, segment_name, segment_value, calculated_at"
        }

        return self.create_schema_for_action("analytics", table_descriptions)

    def create_content_management_schema(self):
        """Create schema for content management agent"""
        table_descriptions = {
            "articles": "Create articles table with id, title, content, author_id, category, status, created_at, updated_at",
            "comments": "Create comments table with id, article_id, user_id, comment_text, created_at, approved",
            "categories": "Create categories table with id, name, description, parent_id",
            "tags": "Create tags table with id, name, description",
            "article_tags": "Create article_tags table with id, article_id, tag_id"
        }

        return self.create_schema_for_action("content_management", table_descriptions)

Testing Schema with Sample Data

import requests

class SchemaValidator:
    def __init__(self, api_key):
        self.api_key = api_key
        self.base_url = "https://api.gibsonai.com/v1/-"
        self.headers = {"Authorization": f"Bearer {api_key}"}

    def validate_schema_with_sample_data(self, schema_name, sample_data):
        """Validate schema by inserting sample data"""
        print(f"Validating schema: {schema_name}")

        success_count = 0
        error_count = 0

        for table_name, records in sample_data.items():
            print(f"Testing table: {table_name}")

            for record in records:
                try:
                    response = requests.post(
                        f"{self.base_url}/{table_name}",
                        json=record,
                        headers=self.headers
                    )

                    if response.status_code == 201:
                        success_count += 1
                        print(f"  ✓ Record inserted successfully")
                    else:
                        error_count += 1
                        print(f"  ✗ Failed to insert record: {response.status_code}")

                except Exception as e:
                    error_count += 1
                    print(f"  ✗ Error inserting record: {e}")

        print(f"\nValidation complete: {success_count} successful, {error_count} errors")
        return error_count == 0

    def test_customer_service_schema(self):
        """Test customer service schema with sample data"""
        sample_data = {
            "customers": [
                {"name": "John Doe", "email": "john@example.com", "phone": "555-0123", "account_status": "active"},
                {"name": "Jane Smith", "email": "jane@example.com", "phone": "555-0456", "account_status": "active"}
            ],
            "support_tickets": [
                {"customer_id": 1, "issue_type": "billing", "description": "Question about billing", "priority": "medium", "status": "open"},
                {"customer_id": 2, "issue_type": "technical", "description": "Login issues", "priority": "high", "status": "open"}
            ]
        }

        return self.validate_schema_with_sample_data("customer_service", sample_data)

    def test_ecommerce_schema(self):
        """Test e-commerce schema with sample data"""
        sample_data = {
            "products": [
                {"name": "Laptop", "description": "High-performance laptop", "price": 999.99, "category": "Electronics", "stock_quantity": 50, "active": True},
                {"name": "Mouse", "description": "Wireless mouse", "price": 29.99, "category": "Electronics", "stock_quantity": 200, "active": True}
            ],
            "orders": [
                {"customer_id": 1, "total_amount": 1029.98, "status": "completed", "payment_method": "credit_card"},
                {"customer_id": 2, "total_amount": 29.99, "status": "processing", "payment_method": "paypal"}
            ]
        }

        return self.validate_schema_with_sample_data("ecommerce", sample_data)

Querying Created Schemas

class SchemaQuerier:
    def __init__(self, api_key):
        self.api_key = api_key
        self.base_url = "https://api.gibsonai.com/v1/-"
        self.headers = {"Authorization": f"Bearer {api_key}"}

    def query_schema_data(self, query_description):
        """Query schema data using natural language"""
        query_request = {
            "query": query_description
        }

        response = requests.post(
            f"{self.base_url}/query",
            json=query_request,
            headers=self.headers
        )

        if response.status_code == 200:
            results = response.json()
            print(f"Query results: {len(results)} records found")
            return results
        else:
            print(f"Query failed: {response.status_code}")
            return None

    def get_customer_service_metrics(self):
        """Get customer service metrics"""
        return self.query_schema_data(
            "Show ticket count by status and average response time for the last 30 days"
        )

    def get_ecommerce_analytics(self):
        """Get e-commerce analytics"""
        return self.query_schema_data(
            "Show total sales, order count, and top-selling products for the last week"
        )

    def get_user_engagement_data(self):
        """Get user engagement data"""
        return self.query_schema_data(
            "Calculate user engagement metrics including page views, session duration, and conversion rates"
        )

Common Schema Patterns

User Management Schema

def create_user_management_schema():
    """Create user management schema"""
    table_descriptions = {
        "users": "Create users table with id, username, email, password_hash, first_name, last_name, created_at, last_login",
        "user_roles": "Create user_roles table with id, user_id, role_name, granted_at",
        "user_sessions": "Create user_sessions table with id, user_id, session_token, expires_at, created_at",
        "user_preferences": "Create user_preferences table with id, user_id, preference_key, preference_value"
    }

    creator = QuickSchemaCreator()
    return creator.create_schema_for_action("user_management", table_descriptions)

Inventory Management Schema

def create_inventory_schema():
    """Create inventory management schema"""
    table_descriptions = {
        "inventory_items": "Create inventory_items table with id, product_id, location, quantity, reserved_quantity, last_updated",
        "stock_movements": "Create stock_movements table with id, product_id, movement_type, quantity, location, timestamp, reference",
        "suppliers": "Create suppliers table with id, name, contact_email, contact_phone, address",
        "purchase_orders": "Create purchase_orders table with id, supplier_id, order_date, status, total_amount"
    }

    creator = QuickSchemaCreator()
    return creator.create_schema_for_action("inventory_management", table_descriptions)

Communication Schema

def create_communication_schema():
    """Create communication schema"""
    table_descriptions = {
        "messages": "Create messages table with id, sender_id, recipient_id, subject, content, sent_at, read_at",
        "notifications": "Create notifications table with id, user_id, notification_type, title, message, read, created_at",
        "communication_logs": "Create communication_logs table with id, user_id, channel, message, timestamp, status"
    }

    creator = QuickSchemaCreator()
    return creator.create_schema_for_action("communication", table_descriptions)

Benefits for Agent Development

Rapid Development

  • Instant Schema Creation: Create database schemas in minutes, not hours
  • Natural Language Interface: Use plain English to describe data structures
  • Immediate APIs: Get REST APIs as soon as schema is created
  • Quick Iteration: Easily modify schemas as requirements change

Flexible Architecture

  • Multiple Schemas: Create different schemas for different agent workflows
  • Easy Modification: Modify existing schemas with simple prompts
  • Test Environments: Create test schemas for validation
  • Production Deployment: Deploy schemas when ready

Integrated Development

  • Model Generation: Automatically generate Python models
  • API Documentation: Get OpenAPI documentation automatically
  • MCP Integration: Connect AI tools through MCP server
  • Text-to-SQL: Query data using natural language

Best Practices

Schema Design

  • Clear Descriptions: Use clear, descriptive natural language
  • Appropriate Relationships: Define relationships between tables
  • Data Types: Let GibsonAI choose appropriate data types
  • Indexing: Consider performance when designing schemas

Development Workflow

  • Start Simple: Begin with simple schemas and evolve
  • Test Early: Test schemas with sample data
  • Iterate: Modify schemas based on testing results
  • Document: Document schema decisions and changes

Production Deployment

  • Validation: Validate schemas thoroughly before production
  • Backup: Ensure proper backup and recovery procedures
  • Monitoring: Monitor schema performance in production
  • Maintenance: Plan for ongoing schema maintenance

Getting Started

  1. Identify Use Case: Determine what type of agent workflow you need
  2. Describe Schema: Use natural language to describe your data structure
  3. Create Schema: Use Gibson CLI to create the database schema
  4. Test Schema: Validate with sample data
  5. Deploy: Deploy to production when ready

Gibson CLI Commands

# Create schema quickly
gibson modify table_name "natural language description"
gibson code models
gibson merge

# Test schema changes
gibson code models
# (test with sample data)
gibson merge

# Reset if needed
gibson forget last

Ready to create database schemas quickly for your AI agent workflows? Get started with GibsonAI.