sql

Develop and optimize SQL queries, design schemas, and advise on indexing strategies.

77|4|Updated Jun 20, 2022
One-click install
npx skills add https://github.com/htlin222/dotfiles --skill sql-htlin222
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql
Source: https://github.com/htlin222/dotfiles/tree/main/claude.symlink/skills/sql
Command: npx skills add https://github.com/htlin222/dotfiles --skill sql-htlin222

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps users write efficient SQL queries, optimize database performance, and design robust database schemas.

Core Features & Use Cases

  • Query Writing: Generate complex SQL queries including window functions and CTEs.
  • Optimization: Analyze query execution plans and implement effective indexing strategies.
  • Schema Design: Create normalized and efficient database schemas.
  • Use Case: Optimize a slow-running SQL query by analyzing its execution plan and adding appropriate indexes.

Quick Start

Use the sql skill to write a query that calculates the 7-day moving average of sales from the 'transactions' table, ordering by date.

Frequently Asked Questions about sql

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I optimize a slow SQL query by analyzing its execution plan?

To optimize a slow SQL query, analyze its execution plan to identify bottlenecks like full table scans, then implement effective indexing strategies to reduce retrieval times and improve overall database performance.

How do I write a SQL query to calculate a 7-day moving average using window functions?

You can write a SQL query to calculate a 7-day moving average by using window functions to define a frame of preceding rows, averaging the sales column while ordering the dataset by date.

What is the best way to design a normalized database schema for relational databases?

The best way to design a normalized database schema is to organize tables to reduce data redundancy and improve integrity, applying relational database principles to structure relationships and ensure efficient data modeling.

When should I add indexes to improve database performance?

You should add indexes to improve database performance when query execution plans reveal slow data retrieval operations, specifically targeting columns frequently used in WHERE clauses or JOIN conditions to accelerate access.

Can I use Common Table Expressions (CTEs) for complex SQL development tasks?

Yes, you can use Common Table Expressions (CTEs) for complex SQL development to temporarily name a result set, making multi-step data transformations and hierarchical queries much easier to read and maintain.