Create database schemas and populate with sample data for AI agent development and testing. Use GibsonAI's natural language database management to quickly set up test environments with realistic data structures.

Key Features

Natural Language Schema Creation

  • Table Definition: Create tables using natural language descriptions
  • Relationship Building: Define relationships between tables naturally
  • Data Type Selection: Automatically choose appropriate data types
  • Index Creation: Add indexes for performance optimization

Sample Data Creation

  • Manual Data Entry: Create sample records through REST APIs
  • Bulk Operations: Insert multiple records at once
  • Realistic Scenarios: Set up data that mirrors real-world use cases
  • Agent Testing: Create data specifically for agent testing scenarios

Implementation Examples

Creating Test Database Schema

# Using Gibson CLI to create schema for agent testing
# Create user management system
# gibson modify users "Create users table with id, username, email, created_at, status"
# gibson modify user_profiles "Create user_profiles table with user_id, first_name, last_name, bio, avatar_url"
# gibson modify conversations "Create conversations table with id, user_id, agent_id, message, response, timestamp"
# gibson modify agent_metrics "Create agent_metrics table with agent_id, metric_name, value, recorded_at"

# Generate Python models
# gibson code models
# gibson merge

Populating with Sample Data

import requests
import random
from datetime import datetime, timedelta

class TestDataGenerator:
    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 create_sample_users(self):
        """Create sample users for testing"""
        sample_users = [
            {"username": "alice_smith", "email": "alice@example.com", "status": "active"},
            {"username": "bob_jones", "email": "bob@example.com", "status": "active"},
            {"username": "charlie_brown", "email": "charlie@example.com", "status": "inactive"},
            {"username": "diana_prince", "email": "diana@example.com", "status": "active"},
            {"username": "eve_wilson", "email": "eve@example.com", "status": "active"}
        ]

        created_users = []
        for user in sample_users:
            response = requests.post(
                f"{self.base_url}/users",
                json=user,
                headers=self.headers
            )
            if response.status_code == 201:
                created_users.append(response.json())
                print(f"Created user: {user['username']}")

        return created_users

    def create_sample_profiles(self, users):
        """Create sample user profiles"""
        profiles = [
            {"first_name": "Alice", "last_name": "Smith", "bio": "Software engineer"},
            {"first_name": "Bob", "last_name": "Jones", "bio": "Product manager"},
            {"first_name": "Charlie", "last_name": "Brown", "bio": "Designer"},
            {"first_name": "Diana", "last_name": "Prince", "bio": "Data scientist"},
            {"first_name": "Eve", "last_name": "Wilson", "bio": "Marketing specialist"}
        ]

        for i, user in enumerate(users):
            if i < len(profiles):
                profile_data = profiles[i]
                profile_data["user_id"] = user["id"]

                response = requests.post(
                    f"{self.base_url}/user-profiles",
                    json=profile_data,
                    headers=self.headers
                )
                if response.status_code == 201:
                    print(f"Created profile for: {user['username']}")

    def create_sample_conversations(self, users):
        """Create sample conversations for agent testing"""
        conversation_templates = [
            {
                "message": "Hello, I need help with my account",
                "response": "I'd be happy to help with your account. What specifically do you need assistance with?"
            },
            {
                "message": "How do I reset my password?",
                "response": "To reset your password, click on 'Forgot Password' on the login page and follow the instructions."
            },
            {
                "message": "I'm having trouble with payments",
                "response": "I understand payment issues can be frustrating. Let me help you resolve this."
            },
            {
                "message": "Can you tell me about your features?",
                "response": "I'd be happy to explain our features. We offer database management, natural language queries, and more."
            }
        ]

        for user in users:
            for template in conversation_templates:
                conversation = {
                    "user_id": user["id"],
                    "agent_id": "agent_001",
                    "message": template["message"],
                    "response": template["response"],
                    "timestamp": datetime.now().isoformat()
                }

                response = requests.post(
                    f"{self.base_url}/conversations",
                    json=conversation,
                    headers=self.headers
                )
                if response.status_code == 201:
                    print(f"Created conversation for: {user['username']}")

    def create_sample_metrics(self):
        """Create sample agent metrics"""
        metrics = [
            {"agent_id": "agent_001", "metric_name": "response_time", "value": 0.5},
            {"agent_id": "agent_001", "metric_name": "satisfaction_score", "value": 4.5},
            {"agent_id": "agent_001", "metric_name": "conversations_handled", "value": 150},
            {"agent_id": "agent_002", "metric_name": "response_time", "value": 0.7},
            {"agent_id": "agent_002", "metric_name": "satisfaction_score", "value": 4.2},
            {"agent_id": "agent_002", "metric_name": "conversations_handled", "value": 120}
        ]

        for metric in metrics:
            metric["recorded_at"] = datetime.now().isoformat()

            response = requests.post(
                f"{self.base_url}/agent-metrics",
                json=metric,
                headers=self.headers
            )
            if response.status_code == 201:
                print(f"Created metric: {metric['metric_name']} for {metric['agent_id']}")

    def generate_all_test_data(self):
        """Generate complete test dataset"""
        print("Creating test data...")

        # Create users
        users = self.create_sample_users()

        # Create profiles
        self.create_sample_profiles(users)

        # Create conversations
        self.create_sample_conversations(users)

        # Create metrics
        self.create_sample_metrics()

        print("Test data creation completed!")
        return users

Using Test Data in Agent Development

class AgentTester:
    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 test_user_lookup(self):
        """Test agent's ability to look up users"""
        query_request = {
            "query": "Show me all active users"
        }

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

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

    def test_conversation_analysis(self):
        """Test agent's ability to analyze conversations"""
        query_request = {
            "query": "Show me all conversations from the last 24 hours with user satisfaction scores"
        }

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

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

    def test_metrics_reporting(self):
        """Test agent's ability to generate metrics reports"""
        query_request = {
            "query": "Calculate average response time and satisfaction score by agent"
        }

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

        if response.status_code == 200:
            results = response.json()
            print("Agent metrics report generated")
            return results
        else:
            print(f"Query failed: {response.status_code}")
            return None

E-commerce Agent Test Data

def create_ecommerce_test_data():
    """Create test data for e-commerce agent"""

    # Create schema
    # gibson modify products "Create products table with id, name, description, price, category, stock_quantity"
    # gibson modify orders "Create orders table with id, customer_id, total, status, created_at"
    # gibson modify order_items "Create order_items table with id, order_id, product_id, quantity, price"
    # gibson modify customers "Create customers table with id, name, email, phone, address"
    # gibson code models
    # gibson merge

    # Sample products
    products = [
        {"name": "Laptop", "description": "High-performance laptop", "price": 999.99, "category": "Electronics", "stock_quantity": 50},
        {"name": "Mouse", "description": "Wireless mouse", "price": 29.99, "category": "Electronics", "stock_quantity": 200},
        {"name": "Coffee Mug", "description": "Ceramic coffee mug", "price": 12.99, "category": "Kitchen", "stock_quantity": 100},
        {"name": "Notebook", "description": "Spiral notebook", "price": 3.99, "category": "Office", "stock_quantity": 300}
    ]

    # Sample customers
    customers = [
        {"name": "John Doe", "email": "john@example.com", "phone": "555-0123", "address": "123 Main St"},
        {"name": "Jane Smith", "email": "jane@example.com", "phone": "555-0456", "address": "456 Oak Ave"}
    ]

    # Sample orders
    orders = [
        {"customer_id": 1, "total": 1029.98, "status": "completed"},
        {"customer_id": 2, "total": 16.98, "status": "pending"}
    ]

    return {"products": products, "customers": customers, "orders": orders}

Testing Scenarios

Customer Service Agent Testing

def test_customer_service_scenarios():
    """Test customer service agent scenarios"""

    # Test user information lookup
    query_request = {
        "query": "Find customer information for user ID 123"
    }

    # Test order history
    query_request = {
        "query": "Show order history for customer john@example.com"
    }

    # Test support ticket creation
    ticket_data = {
        "customer_id": 123,
        "issue": "Password reset request",
        "priority": "medium",
        "status": "open"
    }

Analytics Agent Testing

def test_analytics_scenarios():
    """Test analytics agent scenarios"""

    # Test user engagement metrics
    query_request = {
        "query": "Calculate user engagement metrics for the last 30 days"
    }

    # Test conversation analysis
    query_request = {
        "query": "Analyze conversation sentiment and response times"
    }

    # Test performance trends
    query_request = {
        "query": "Show agent performance trends over the last week"
    }

Use Cases

Agent Development

Perfect for:

  • Creating realistic test environments
  • Testing agent responses to various scenarios
  • Validating agent performance with sample data
  • Debugging agent database interactions

Schema Validation

Enable:

  • Testing database schema with realistic data
  • Validating data relationships and constraints
  • Ensuring data integrity across operations
  • Testing schema evolution with existing data

Performance Testing

Support:

  • Load testing with sample datasets
  • Query performance validation
  • Database optimization testing
  • Scalability testing with realistic data volumes

Best Practices

Test Data Design

  • Realistic Data: Create data that mimics real-world scenarios
  • Comprehensive Coverage: Include edge cases and boundary conditions
  • Data Relationships: Ensure proper relationships between tables
  • Data Variety: Include different data types and formats

Testing Strategy

  • Incremental Testing: Start with simple scenarios and build complexity
  • Automated Testing: Create scripts for repeatable test data generation
  • Data Cleanup: Clean up test data after testing
  • Version Control: Track test data changes with schema evolution

Data Management

  • Separation: Keep test data separate from production data
  • Documentation: Document test data scenarios and purposes
  • Maintenance: Regularly update test data to reflect schema changes
  • Security: Ensure test data doesn't contain sensitive information

Gibson CLI Commands

# Create database schema
gibson modify table_name "description of table structure"
gibson code models
gibson merge

# Reset database for fresh testing
gibson forget last
gibson build datastore

# Generate models after schema changes
gibson code models
gibson code schemas

Benefits for AI Agent Testing

  • Rapid Setup: Quick schema creation using natural language
  • Realistic Testing: Create scenarios that mirror production usage
  • Flexible Data: Easy to modify test data as needs change
  • Natural Queries: Test agents with natural language database queries
  • Automated APIs: Immediate access to REST APIs for data operations

Getting Started

  1. Define Schema: Use natural language to create your database schema
  2. Generate Models: Create Python models with Gibson CLI
  3. Create Test Data: Populate database with sample data
  4. Test Agent Operations: Validate agent functionality with test data
  5. Iterate and Improve: Refine schema and data based on testing results

Ready to create database schemas and test data for your AI agents? Get started with GibsonAI.