~/VibeHandbook
$39

Languages

iso.org

SQL

What it is

SQL (Structured Query Language) is the standard language for querying and manipulating relational databases like PostgreSQL, MySQL, SQLite, and SQL Server. It's declarative — you describe the result you want, and the database engine figures out how to fetch it efficiently.

Strengths

  • Declarative: state what you want, not how to loop over rows.
  • Decades-proven, with mature engines and strong consistency guarantees.
  • Set-based operations (joins, aggregates, window functions) are concise and fast.
  • Transferable — core SQL works across most relational databases.

Trade-offs

  • Dialects differ (Postgres vs. MySQL vs. SQLite), so portability isn't total.
  • Easy to write slow queries; performance depends on indexes and query plans.
  • Not a general-purpose language — control flow and logic are awkward.
  • Schema changes (migrations) need care in production.

When to reach for it

Reach for SQL whenever your data is relational and queried by structure: reporting, analytics, application backends, and any system where data integrity and joins matter. It's the right tool for aggregations and ad-hoc questions over structured data, and it pairs with nearly every backend language.

Vibe coding fit

AI assistants are strong at SQL and can translate plain-English questions into queries surprisingly well, but they may guess at your schema. Direct the AI by pasting the actual table definitions (CREATE TABLE statements) and naming your specific database (Postgres, SQLite, etc.) so it uses the correct dialect and functions. Ask it to explain the query and to suggest indexes for slow ones, and always have it parameterize user input rather than string-concatenating values — that prevents SQL injection. Verify generated queries on a small sample before running against production.

SELECT u.name, COUNT(o.id) AS order_count
FROM users u
LEFT JOIN orders o ON o.user_id = u.id
WHERE u.active = true
GROUP BY u.name
HAVING COUNT(o.id) > 5
ORDER BY order_count DESC;