askill
db-naming-conventions

db-naming-conventionsSafety 100Repository

Naming conventions for relational databases: databases, tables, columns, indexes, constraints, and enums. Applies to SQL migrations, sqlc queries, and ER diagrams in Mermaid. Trigger: When creating database tables, writing migrations, designing ER diagrams, or naming columns and constraints.

0 stars
1.2k downloads
Updated 2/9/2026

Package Files

Loading files...
SKILL.md

When to Use

  • Creating new database tables or modifying existing schemas
  • Writing SQL migrations (golang-migrate, Flyway, etc.)
  • Designing ER diagrams in Mermaid (.mmd files)
  • Reviewing naming consistency between diagrams and migrations
  • Adding indexes, constraints, or foreign keys

Dependencies

SkillPurposePath
go-repository-patternMigration files, sqlc queries follow these naming rules../go-repository-pattern/SKILL.md
mermaid-diagramsER diagrams must use the same naming as SQL../mermaid-diagrams/SKILL.md

Core Principle

One naming convention governs everything: ER diagrams, SQL migrations, sqlc queries, and application code mappings. Zero translation, zero ambiguity. What the diagram says is what the migration creates.


Critical Rules

Databases

RuleConventionExample
Formatsnake_casebastet, bastet_production
Environment suffixOnly when multiple DBs on same serverbastet_dev, bastet_staging

Tables

RuleConventionExample
Formatsnake_caseusers, pet_sitters
PluralityAlways pluralbookings, NOT booking
No prefixesNever tbl_, t_users, NOT tbl_users
Join tablesAlphabetical order or semantic namepets_services or pet_sitter_certifications

Columns

RuleConventionExample
Formatsnake_casefirst_name, phone_number
Primary keyAlways idid UUID PRIMARY KEY
Foreign key{singular_table}_iduser_id, pet_sitter_id
BooleansPrefix is_ or has_is_active, has_premium
TimestampsSuffix _atcreated_at, updated_at, deleted_at
CountsSuffix _countbooking_count, review_count
MonetarySuffix _cents (store as integer)price_cents, fee_cents

Indexes

TypePatternExample
Regular indexidx_{table}_{columns}idx_users_email
Unique indexuq_{table}_{columns}uq_users_email
Compositeidx_{table}_{col1}_{col2}idx_bookings_user_id_status

Constraints

TypePatternExample
Primary keypk_{table}pk_users
Foreign keyfk_{source}_{target}fk_bookings_users
Checkck_{table}_{column}ck_bookings_status
Uniqueuq_{table}_{columns}uq_users_email

Enum / Status Values

RuleConventionExample
Type namesnake_casebooking_status, payment_status
ValuesUPPER_SNAKE_CASEPENDING, IN_PROGRESS, COMPLETED

ER Diagrams in Mermaid

ER diagrams MUST mirror SQL naming exactly. This means:

ElementIn SQLIn Mermaid ERMatch?
Table nameusersusersYes
Column namefirst_namefirst_nameYes
Foreign keyuser_iduser_id FKYes
Primary keyidid PKYes
Data typeUUIDuuidLowercase in Mermaid

See assets/example-er.mmd for a complete ER diagram following these conventions.

See assets/example-migration.sql for the matching SQL migration.


Anti-Patterns

Don'tDoWhy
UPPER_CASE entity names in ERsnake_case plural matching SQLDiagram must match implementation
camelCase columns in ER diagramssnake_case matching SQLZero translation between diagram and migration
userId as foreign keyuser_idConsistent snake_case
tbl_users, t_usersusersPrefixes add noise, zero value
booking (singular table)bookings (plural)Table holds a collection
active (boolean without prefix)is_activePrefix makes intent obvious
price DECIMALprice_cents INTEGERInteger cents avoid float rounding
data, info, details columnsSpecific namesVague names hide meaning
id INTEGER AUTO_INCREMENTid UUIDUUIDs are safer for distributed systems

Commands

# Create a migration with proper naming
migrate create -ext sql -dir migrations -seq create_bookings

# Validate table naming in existing migrations
rg "CREATE TABLE" migrations/ --no-heading

Checklist

  • Table names are snake_case and plural
  • Columns are snake_case and singular
  • Primary key is id (UUID)
  • Foreign keys follow {singular_table}_id pattern
  • Booleans have is_ or has_ prefix
  • Timestamps end in _at
  • Indexes follow idx_{table}_{columns} pattern
  • Constraints follow {type}_{table}_{detail} pattern
  • ER diagram entity names match SQL table names exactly
  • ER diagram column names match SQL column names exactly
  • Monetary values stored as integer cents with _cents suffix

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

93/100Analyzed 2/19/2026

Excellent database naming conventions skill with comprehensive coverage of SQL and Mermaid ER diagrams. Well-structured with tables, examples, anti-patterns, and a verification checklist. Clear triggers and dependencies on related skills. Slight deduction for external file dependencies but overall highly actionable and reusable.

100
95
90
88
92

Metadata

Licenseunknown
Version-
Updated2/9/2026
Publisher333-333-333

Tags

database