Backend Models

Create ORM models with constraints, relationships, and indexes across frameworks.

6|1|Updated Nov 12, 2022
One-click install
npx skills add https://github.com/coreyja/coreyja.com --skill backend-models-coreyja
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Backend Models
Source: https://github.com/coreyja/coreyja.com/tree/main/.claude/skills/backend-models
Command: npx skills add https://github.com/coreyja/coreyja.com --skill backend-models-coreyja

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill ensures database models are well-defined, maintain data integrity, and accurately represent application entities, simplifying data management and reducing errors.

Core Features & Use Cases

  • Data Integrity: Guides the definition of appropriate data types, constraints (NOT NULL, UNIQUE), and foreign key relationships.
  • Clear Structure: Ensures models have clear naming, timestamps, and indexes for optimal performance and maintainability.
  • Use Case: When creating a new Product model, use this skill to define its attributes with correct data types (e.g., DECIMAL for price), add created_at and updated_at timestamps, and establish a foreign key relationship to a Category model.

Quick Start

Apply the Backend Models skill to define a new 'InvoiceItem' model, including fields for quantity, price, and a foreign key relationship to the 'Invoice' model, ensuring proper data types and constraints.

Frequently Asked Questions about Backend Models

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

FAQPage Schema
How do I define ORM models with proper data types and constraints?

Define ORM models by specifying appropriate column data types (DECIMAL for prices, VARCHAR for strings), adding NOT NULL and UNIQUE constraints, and establishing foreign key relationships. This ensures data integrity and prevents invalid entries in your database.

What's the best way to set up relationships between database tables?

Configure table relationships (one-to-many, many-to-many, one-to-one) through foreign keys with cascade behaviors in your ORM framework. This maintains referential integrity and automates deletion or update propagation across related records.

Does this work with SQLAlchemy, Sequelize, ActiveRecord, and other ORMs?

Yes, Backend Models supports SQLAlchemy, Sequelize, ActiveRecord, SQLx, Diesel, and Prisma. Apply the same modeling principles—data types, constraints, timestamps, and indexes—across all supported frameworks.

How do I add timestamps and indexes to improve database performance?

Include created_at and updated_at timestamp columns and create indexes on frequently queried or foreign key columns. Timestamps track record changes; indexes accelerate lookups and enforce uniqueness constraints.

When should I use CHECK constraints and cascade rules on foreign keys?

Use CHECK constraints to enforce business logic (e.g., price > 0) and cascade rules to automatically delete or update child records when parent records change. Both prevent orphaned data and maintain consistency.

What naming conventions should I follow for models and columns?

Apply consistent naming conventions across your ORM models—use snake_case for columns, PascalCase for model names, and descriptive names reflecting the data they hold. This improves readability and maintains standards across frameworks.