Database Connections
- Published on
Learn how to configure and manage your database connections.
Setting Up a New Connection
- Navigate to the Connections page
- Click Add New Connection
- Fill in the following details:
- Connection name
- Database type (from supported databases)
- Database schema
Schema Format Guidelines
The schema format is flexible and supports multiple database types. You can include:
- Tables and their structures
- Column names and types
- Relationships between tables
- Comments to provide context for the AI
💡 Tip: Adding comments helps the AI better understand your database structure and relationships.
Example Schemas
PostgreSQL Example
-- E-commerce Database Schema
products (
id: serial primary key,
name: varchar(255), -- Product display name
price: decimal(10,2), -- Current selling price
stock: integer, -- Available quantity in inventory
category_id: integer references categories(id) -- Product classification
)
categories (
id: serial primary key,
name: varchar(100), -- Category display name
description: text -- Detailed category description
)
-- Orders can have multiple products
orders (
id: serial primary key,
customer_id: integer, -- References customer making the purchase
order_date: timestamp, -- When the order was placed
status: varchar(50) -- Current order status (pending, shipped, delivered, etc.)
)
MySQL Example
# School Management System
students (
id: int auto_increment primary key,
first_name: varchar(50),
last_name: varchar(50),
date_of_birth: date, # Used for age verification and reports
grade: int, # Current grade level
email: varchar(100) unique # Primary contact method for students
)
courses (
id: int auto_increment primary key,
name: varchar(100), # Full course title
credits: int, # Number of credits awarded
department: varchar(50) # Academic department offering the course
)
# Junction table for many-to-many relationship
enrollments (
student_id: int,
course_id: int,
enrollment_date: datetime, # When student enrolled in the course
grade: decimal(4,2) # Final grade achieved (0.00-100.00)
)
MongoDB Example
// Blog Platform
posts: {
_id: ObjectId,
title: String, // Post headline
content: String, // Main post content
author: {
_id: ObjectId,
name: String, // Author's display name
email: String // Author's contact email
},
tags: Array<String>, // Categories/topics for the post
comments: [{
user: String, // Commenter's username
content: String, // Comment text
created_at: Date // When comment was posted
}],
created_at: Date, // When post was first published
updated_at: Date // Last modification timestamp
}
users: {
_id: ObjectId,
username: String, // Unique username for login
email: String, // Primary contact method
profile: {
bio: String, // User's self description
avatar_url: String, // Profile picture URL
social_links: {
twitter: String, // Twitter profile URL
github: String // GitHub profile URL
}
}
}
Best Practices
- Use Clear Names: Choose descriptive names for your connections that reflect their purpose
- Add Comments: Include comments in your schema to explain relationships and table purposes
- Be Consistent: Maintain consistent formatting in your schema definitions
- Document Relationships: Clearly indicate foreign key relationships and constraints