v1.31.0
guíaPatrón · 05_Plantillas_SQLenglishversión en español

📁 SQL Templates - Database

2 minlectura
352palabras
8secciones
2026-09-22última edición
1cambios

Description

This folder holds standard templates for SQL Server database objects. They follow the naming conventions and standards the ecosystem defines.

Contents

FileDescription
PLANTILLA_STORED_PROCEDURE.sqlFull template for stored procedures
PLANTILLA_TABLA.sqlTable template with audit columns
PLANTILLA_TABLA_CATALOGO.sqlTemplate for catalogue/lookup tables
PLANTILLA_VISTA.sqlStandard view template
PLANTILLA_FUNCION.sqlFunction templates (scalar and table-valued)
PLANTILLA_MIGRACION.sqlMigration script with rollback
CONVENCION_SCHEMAS.sqlRecommended schema structure

The file names stay as they are: the skills point at those exact paths.

How to use them

  1. Copy the template you need
  2. Rename it after the object you are creating
  3. Replace the {...} placeholders with real values
  4. Delete the sections that do not apply
  5. Review it before running it in production

Naming Conventions

Database objects

ObjectConventionExample
TablePascalCase, singularStudent, ScholarshipApplication
Catalogue tablePascalCase, singularDocumentType, ApplicationStatus
ColumnPascalCaseBirthDate, DocumentNumber
Stored procedureusp_{Entity}_{Action}usp_Student_GetById
Viewvw_{Description}vw_ActiveStudents
Scalar functionfn_{Description}fn_CalculateAge
Table-valued functionfnt_{Description}fnt_ScholarshipsByStudent
Triggertr_{Table}_{Event}tr_Student_AfterInsert
IndexIX_{Table}_{Columns}IX_Student_Email
Unique indexUX_{Table}_{Columns}UX_Student_DocumentNumber
Primary keyPK_{Table}PK_Student
Foreign keyFK_{ChildTable}_{ParentTable}FK_ScholarshipApplication_Student
CheckCK_{Table}_{Column}CK_Student_Age
DefaultDF_{Table}_{Column}DF_Student_RegisteredAt
Schemalowercaseacademico, financiero

The verbs and the object names are in English; the schema names are the organization's own and are not translated. Which verbs are allowed is set by database.naming.allowedVerbs.

Stored procedure prefixes

PrefixUsed forExample
usp_{Entity}_InsertInsertusp_Student_Insert
usp_{Entity}_UpdateUpdateusp_Student_Update
usp_{Entity}_DeleteHard deleteusp_Student_Delete
usp_{Entity}_SoftDeleteSoft deleteusp_Student_SoftDelete
usp_{Entity}_GetByIdGet by IDusp_Student_GetById
usp_{Entity}_GetAllList with pagingusp_Student_GetAll
usp_{Entity}_SearchAdvanced searchusp_Student_Search
usp_{Entity}_ExistsCheck existenceusp_Student_Exists
usp_Rpt_{Name}Reportsusp_Rpt_EnrollmentsByDegree

Audit columns (MANDATORY)

Every table must include these columns:

-- Mandatory
Active BIT NOT NULL DEFAULT 1,
CreatedAt DATETIME2(3) NOT NULL DEFAULT GETUTCDATE(),
CreatedBy NVARCHAR(100) NOT NULL DEFAULT SYSTEM_USER,
ModifiedAt DATETIME2(3) NULL,
ModifiedBy NVARCHAR(100) NULL

Environments

EnvironmentVersion
Main productionSQL Server 2017+
New applicationsSQL Server 2019/2022
CloudAzure SQL

Reference

  • Full rule: .claude/skills/database/SKILL.md
  • SQL Server documentation: https://docs.microsoft.com/sql

Fuente: ovillo/_patron/05_Plantillas_SQL/README_EN.md

Ovillo v1.31.0tag v1.31.0 (2026-10-06) · sin decisiones posteriores69 skills · 19 agents · 22 hooks · 3 reglas · 15 tools · 103 decisionesfuente: ovillo/_patron/05_Plantillas_SQL/README_EN.mdCopyright 2026 Hugo Valer Rojas · Apache-2.0