sql

Provide guidance for writing set-based SQL queries and data modeling patterns.

Updated Feb 17, 2026
One-click install
npx skills add https://github.com/Objective-Arts/lens-dist --skill sql-objective-arts
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql
Source: https://github.com/Objective-Arts/lens-dist/tree/main/canon/sql
Command: npx skills add https://github.com/Objective-Arts/lens-dist --skill sql-objective-arts

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers and data professionals write more efficient and idiomatic SQL by focusing on set-based operations rather than procedural logic, leading to faster queries and more maintainable code.

Core Features & Use Cases

  • Set-Based Thinking: Understand and apply the core philosophy of SQL as a declarative, set-based language.
  • Pattern Implementation: Learn and implement common SQL patterns for hierarchies (Nested Sets), temporal data, and query optimization.
  • Anti-Pattern Avoidance: Identify and avoid common SQL anti-patterns like cursors, explicit loops, and SELECT *.
  • Use Case: Refactor a slow, cursor-based SQL query into a performant set-based update statement.

Quick Start

Use the sql skill to demonstrate set-based thinking by refactoring a procedural SQL update into a set-based one.

Frequently Asked Questions about sql

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

FAQPage Schema
How do I refactor a slow SQL cursor into a set-based query?

Refactoring a slow SQL cursor into a set-based query involves replacing procedural row-by-row loops with declarative update statements. This approach processes entire data sets simultaneously, leading to faster queries and more maintainable database code.

What is the best way to model hierarchical data in SQL?

Modeling hierarchical data in SQL is best achieved using the nested sets pattern. This set-based approach represents tree structures by assigning left and right numerical bounds to nodes, enabling efficient hierarchical queries without procedural loops.

How do I handle temporal data with valid time intervals in SQL?

Handling temporal data in SQL requires implementing valid time intervals to track history. You structure tables to store start and end dates for each record, ensuring accurate point-in-time queries without relying on procedural logic.

What are common SQL anti-patterns to avoid for query optimization?

Common SQL anti-patterns include using explicit loops, cursors, and SELECT * statements. Avoiding these procedural habits and adopting set-based operations ensures efficient query optimization and cleaner data modeling.

Why does set-based SQL perform better than procedural loops?

Set-based SQL performs better because it leverages the database engine's internal optimizations for declarative operations. Procedural loops force row-by-row processing, while set-based queries manipulate entire sets simultaneously, drastically reducing execution overhead.

Do I need to follow specific naming conventions for SQL data modeling?

Following consistent naming conventions for tables and columns is essential for maintainable SQL data modeling. Standardized names improve code readability and prevent ambiguity when implementing complex set-based queries and data structures.