Use when writing or reviewing MSSQL/T-SQL, creating stored procedures, designing table schemas, writing views, building migrations, defining custom types, or architecting a SQL Server application database. Also use when writing RAISERROR patterns, CHECK constraints with scalar functions, base/subtype table hierarchies, composite key designs, role-scoped views with row-level security, or idempotent DDL scripts. If you are touching MSSQL for an application database, use this skill. Not for PostgreSQL, MySQL, Oracle, or SQLite — patterns are SQL Server-specific.
95
94%
Does it follow best practices?
Impact
98%
1.81xAverage score across 5 eval scenarios
Passed
No known issues
A public library district is modernizing its catalog and lending software. The tech team needs a clean SQL Server schema for the core domain: books, members, and loans. The existing prototype was written hastily with raw SQL types everywhere, inconsistent nullability, and constraint names that are meaningless in error logs. The team wants to start fresh with a maintainable schema that will serve as the foundation for the next decade of development.
The library manages a catalog of books (with authors, ISBN, and genre classification), members who can borrow books, and loan records that track which member has which book and when it's due. Books can be in one of several states (Available, OnLoan, Reserved, Lost). Members have a membership tier (Standard, Premium, Staff). The schema should enforce these classifications at the database level.
The developer's job is to produce the foundational DDL for this system: the custom type definitions, reference/lookup tables, and the core entity tables with proper relationships. The schema does not need stored procedures yet — just the structural layer.
Produce a single SQL script file named schema.sql that contains:
types.yaml that serves as the central manifest documenting all custom types with their underlying base type and default valueBook, Author, Book_Author (associative), Member, and LoanThe SQL script should be self-contained and runnable on a fresh SQL Server database.