Knowledge Base

Upload schema definitions, business logic, and example queries to your Knowledge Base so Formula Bot generates more accurate SQL for your database.

Upload documentation files to give Formula Bot additional context about your database. This helps generate more accurate SQL queries by providing information about schema definitions, business logic, and query patterns.

Knowledge Base is available on Pro and Max plans for SQL data sources (BigQuery, Snowflake, MySQL, PostgreSQL, MSSQL).

Why Use a Knowledge Base?

Raw database schemas don't always tell the full story. A Knowledge Base helps Formula Bot understand:

  • Column meanings - What does cust_stat_cd actually represent?
  • Business definitions - How do you define "active customer" or "revenue"?
  • Table relationships - Which tables join together and how?
  • Common calculations - Standard formulas for metrics like conversion rate or LTV
  • Query patterns - Example queries that work well with your data

Benefits

More Accurate Queries

With context about your data, Formula Bot generates SQL that matches your business logic and terminology.

Fewer Follow-ups

Clear definitions reduce back-and-forth clarification questions.

Consistent Results

Documented business rules ensure consistent metric calculations across queries.

Faster Results

Understanding your schema helps the AI focus on relevant tables and columns.

Accessing Knowledge Base

  1. Go to My Data in the dashboard
  2. Switch to the Connectors tab
  3. Find your SQL connector and click the menu icon
  4. Select Knowledge Base

Supported File Types

Upload any of these formats:

  • Documents: PDF, DOCX, TXT, MD
  • Web: HTML, JSON
  • Code: JS, TS, PY, RB, PHP, GO, JAVA, C, CPP, CS
  • Presentations: PPTX
  • Other: TEX, SH

What to Include

Schema Definitions

Document the purpose and meaning of tables and columns:

[TABLE_PURPOSE]
customers: Each row represents a registered customer.
orders: Each row represents a purchase made by a customer.
products: Catalog of available items.

[COLUMN_MEANINGS]
orders.total_price: Derived as quantity * product price.
customers.signup_date: First date the customer joined.
customers.cust_stat_cd: Status code (A=Active, I=Inactive, S=Suspended)

[PRIMARY_KEYS]
customers: customer_id
orders: order_id

[FOREIGN_KEYS]
orders.customer_id -> customers.customer_id
orders.product_id -> products.product_id

Business Logic

Define calculations and business terms:

[CALCULATIONS]
revenue = SUM(orders.total_price)
average_order_value = revenue / COUNT(DISTINCT orders.order_id)
customer_lifetime_value = total_revenue / number_of_customers
conversion_rate = conversions / visits

[BUSINESS_DEFINITIONS]
active_customer: Customer who placed an order in the last 12 months.
new_customer: Customer whose first order was within 30 days.
churned_customer: No orders in the last 6 months.
high_value_customer: Lifetime revenue > $500.

[FILTER_LOGIC]
exclude_internal_users: email NOT LIKE '%@test.com'
exclude_refunded: status != 'refunded'

Example Queries

Provide working query examples:

-- Total revenue by product category
SELECT
  p.product_type,
  SUM(o.total_price) AS revenue
FROM orders o
JOIN products p ON o.product_id = p.product_id
GROUP BY p.product_type;

-- Note: Use product_type for categories, not product_name

-- Daily sales trend
SELECT
  order_date,
  SUM(total_price) AS daily_revenue
FROM orders
GROUP BY order_date
ORDER BY order_date;

-- Note: Always ORDER BY date for time series

Ambiguities and Common Mistakes

Document potential confusion points:

[AMBIGUITIES]
"product" = product name; "product_type" = category
"total sales" = SUM(total_price), not COUNT(*)
"active customers" = customers with orders in last 12 months

[COMMON_MISTAKES]
- Using product_name instead of product_type when grouping by category
- Using COUNT(*) instead of SUM(total_price) for revenue
- Forgetting to exclude test/internal accounts

Uploading Files

Drag and Drop

Drag files directly into the upload area.

Browse

Click the upload area to open a file browser.

Multiple Files

Upload multiple files at once. They'll be processed sequentially.

Managing Files

View Existing Files

All uploaded files appear below the upload area with their names and sizes.

Download Files

Click the download icon to retrieve a file.

Delete Files

Click the trash icon to remove a file from the knowledge base.

Template

Download our sample template for a structured starting point:

  1. Open Knowledge Base for your connector
  2. Click Download sample template
  3. Fill in the sections relevant to your database
  4. Upload the completed file

Best Practices

Be Specific

Instead of "sales data," explain exactly what columns mean and how they should be used.

Use Plain Language

Write definitions that would help a new team member understand your data.

Include Examples

Real query examples are often more helpful than abstract definitions.

Keep It Updated

When your schema or business logic changes, update the knowledge base.

Focus on Problem Areas

If certain queries consistently need correction, document those specific cases.

How It Works

When you query your connected database:

  1. Formula Bot retrieves your knowledge base files
  2. The content is included as context for SQL generation
  3. The AI uses your definitions and examples to write accurate queries
  4. Business logic and calculations follow your documented rules

Multiple Files

You can upload multiple files to your knowledge base. Common patterns:

  • Single comprehensive file - All documentation in one document
  • Separate by topic - schema.md, business_logic.md, examples.sql
  • Separate by table - customers.md, orders.md, products.md

All files are combined when generating queries.

Troubleshooting

Upload Fails

  • Check file type is supported
  • Ensure file isn't corrupted
  • Verify file size is reasonable (under 10 MB)

Context Not Applied

  • Confirm files uploaded successfully (appear in file list)
  • Try re-uploading the file
  • Check the content is in a readable format (not scanned images)

Queries Still Inaccurate

  • Add more specific examples for problem areas
  • Include common mistakes to avoid
  • Add explicit definitions for ambiguous terms

Plan Requirements

Knowledge Base is available on:

  • Pro - Full access
  • Max - Full access

Free and Starter plans do not include Knowledge Base. Upgrade to add context files to your connectors.

Next Steps