Database Schema
The DB Schema resource provides a live, interactive representation of your application’s database structure. From here, you can browse tables, inspect columns and indexes, review comments, and receive AI-driven guidance tailored to your exact schema.
Navigation: Access DB Schema via the sidebar under the “DB Schema” section.
1. Schema Explorer
Section titled “1. Schema Explorer”Upon opening the DB Schema page, you will see an interactive interface where all database tables are listed. The explorer allows you to drill down into table details, search for specific tables or columns, and review associated metadata.
1.1 Table Listing & Filtering
Section titled “1.1 Table Listing & Filtering”-
Table List
- Displays all tables in your current database. Each row shows the Table Name and optionally a brief Table Comment (if provided).
-
Search Filter
- A search field at the top enables you to quickly locate tables by name or by keywords found in table comments. Typing a partial table name or keyword will narrow the list immediately.
-
Column & Index Visibility
- Clicking on a table row expands it to reveal:
- Columns: Each column’s name, data type, nullability, default value, and column comment (if provided).
- Indexes: For each index defined on the table, you’ll see the index name, type (e.g., PRIMARY, UNIQUE, INDEX), and the columns included.
- Foreign Keys: If applicable, foreign key constraints are displayed beneath indexes, showing referenced tables and columns.
- Table Comment: If the table has an overall comment, it appears at the top of the expansion panel.
- Clicking on a table row expands it to reveal:
Tip: Use the search filter to match columns or table comments as well. This helps you find a specific column name even if you don’t remember the exact table name.
1.2 Column & Index Details
Section titled “1.2 Column & Index Details”-
Column Metadata
- For each column, you can see:
- Name (e.g.,
user_id
,email
) - Type (e.g.,
VARCHAR(255)
,INT unsigned
) - Nullable (whether
NULL
is allowed) - Default Value (if any)
- Column Comment (if documented)
- Name (e.g.,
- For each column, you can see:
-
Index Metadata
- Under the Indexes section, you’ll find:
- Index Name (e.g.,
PRIMARY
,users_email_unique
) - Index Type (e.g.,
PRIMARY KEY
,UNIQUE
,INDEX
) - Indexed Columns (ordered list of column names in the index)
- Index Name (e.g.,
- Under the Indexes section, you’ll find:
-
Foreign Key Constraints
- If the table has any foreign keys, a “Foreign Keys” subsection lists:
- Constraint Name (e.g.,
orders_user_id_foreign
) - Local Column(s)
- Referenced Table & Column(s)
- Constraint Name (e.g.,
- If the table has any foreign keys, a “Foreign Keys” subsection lists:
Tip: An interactive sort control (when available) lets you reorder tables by name or by creation date. You can also collapse all expanded tables at once to reduce visual clutter.
2. Ask AI Button
Section titled “2. Ask AI Button”In the top-right corner of the DB Schema interface, you will find an Ask AI button. Clicking this opens a chat dialog where Laritor’s AI engine—fully aware of your exact database schema—can assist with a variety of schema-related tasks.
2.1 Chat Dialog Capabilities
Section titled “2.1 Chat Dialog Capabilities”Once you click Ask AI, a conversational window appears. You can interact with the AI just as you would with any chat interface, asking follow-up questions and refining your queries. The AI understands your schema context, so it can provide tailored advice. Examples of supported prompts include:
-
Schema Optimization
- “Suggest indexing strategies to optimize the
orders
table for queries filtering byuser_id
andcreated_at
.” - “My
products
table has grown to 10 million rows—how should I partition or index to improve query performance?”
- “Suggest indexing strategies to optimize the
-
Column & Table Design
- “Recommend data type changes for the
email
column inusers
to reduce storage and improve lookups.” - “Are there any tables missing foreign key constraints for referential integrity?”
- “Recommend data type changes for the
-
Generating SQL
- “Show me a SQL query to join
orders
withorder_items
and group results byproduct_id
, returning total quantity sold.” - “Give me a CREATE INDEX statement for the
reviews
table to speed up lookups on(product_id, rating)
.”
- “Show me a SQL query to join
-
Normalization & Refactoring
- “Evaluate if the
user_profiles
table should be merged intousers
, or if it’s best to keep it separate given its columns.” - “Suggest how to denormalize the
sales
table for faster reporting.”
- “Evaluate if the
Tip: The chat dialog maintains context across follow-up questions. For instance, after asking about the
orders
table, you can follow up with “Now show me how to add a composite index on(user_id, status)
,” and the AI will understand you’re still referring toorders
.
2.2 Dialog Features
Section titled “2.2 Dialog Features”-
Interactive Conversation
- The AI chat supports multiple question/answer turns, so you can refine or deepen requests.
-
Schema-Aware Responses
- All suggestions and generated SQL code explicitly reference your actual table and column names—no generic placeholders.
-
Exportable Snippets
- When the AI provides SQL statements or index definitions, you can copy them directly for use in your database client or migration files.
3. Best Practices
Section titled “3. Best Practices”-
Familiarize Yourself with the Schema Navigator
- Before using AI assistance, browse through your tables and columns to ground yourself in the structure. This will help you ask more precise questions.
-
Use Search to Narrow Focus
- If you have hundreds of tables, use the search filter to locate the relevant table (for example, type “audit” to find all audit-related tables).
-
Validate AI Recommendations
- Always review and test any SQL or index suggestions in a staging environment before applying changes to production.
- Leverage your query profiler or explain plans to confirm that new indexes actually improve performance.
-
Iterate Over Follow-Up Questions
- The chat dialog’s context awareness allows you to ask follow-up questions such as “Can you tune that index suggestion further if I also need to filter by
status
?” or “What would the ALTER TABLE command look like?”
- The chat dialog’s context awareness allows you to ask follow-up questions such as “Can you tune that index suggestion further if I also need to filter by
-
Document Schema Changes
- If the AI recommends altering a table or adding indexes, record those changes in your version control or migration scripts to maintain schema consistency across environments.
-
Combine with Performance Monitoring
- After making schema changes based on AI guidance, use Laritor’s Queries and Requests resources to monitor for performance improvements (e.g., reduced query durations or fewer N+1 query patterns).
By leveraging the interactive DB Schema explorer and the AI-powered Ask AI dialog, Laritor empowers you to understand, optimize, and evolve your database schema with confidence—receiving tailored advice that directly reflects your unique table structures, column definitions, and indexing strategies.