relational-db-general

General Relational Database Principles

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "relational-db-general" with this command: npx skills add sraloff/gravityboots/sraloff-gravityboots-relational-db-general

General Relational Database Principles

This skill provides core guidelines for designing and interacting with relational databases (MySQL, PostgreSQL, etc.).

When to use this skill

  • Designing new database schemas (DDL).

  • Reviewing or refactoring existing tables.

  • Writing complex SQL queries that involve joins or transactions.

  • troubleshooting data integrity issues.

  1. Naming Conventions
  • Tables: Plural_snake_case (e.g., users , order_items ).

  • Columns: snake_case (e.g., is_active , created_at ).

  • Primary Keys: id (or product_id if strictly required by convention, but id preferred for simplicity).

  • Foreign Keys: singular_table_name_id (e.g., user_id references users.id ).

  • Indexes: idx_table_columns ; Unique: uniq_table_columns .

  1. Normalization Rules
  • 1NF: Atomic values, no repeating groups.

  • 2NF: No partial dependencies (all non-key columns depend on the full PK).

  • 3NF: No transitive dependencies (depend only on the key, nothing but the key).

  • Exceptions: Denormalize only for proven performance bottlenecks (e.g., caching counts), and document widely.

  1. Keys & Constraints
  • Primary Keys: Always use a Primary Key (integer/bigint AUTO_INCREMENT or UUID).

  • Foreign Keys: Enforce referential integrity at the database level (ON DELETE RESTRICT or CASCADE ).

  • Unique Constraints: Enforce uniqueness in DB, not just application code.

  • Not Null: Default to NOT NULL unless optionality is strictly required.

  1. ACID Compliance
  • Atomicity: Wrap related writes in a Transaction (BEGIN ... COMMIT ).

  • Consistency: Data must meet validation rules at all times.

  • Isolation: Understand isolation levels (e.g., Read Committed vs. Serializable).

  • Durability: Committed data is permanent.

  1. Performance Tips
  • Index columns used in WHERE , JOIN , and ORDER BY .

  • Avoid SELECT * .

  • Use correct data types (e.g., TINYINT for booleans, DECIMAL for currency).

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

apache-lamp-config

No summary provided by upstream source.

Repository SourceNeeds Review
General

caddy-modern-config

No summary provided by upstream source.

Repository SourceNeeds Review
General

bootstrap-legacy

No summary provided by upstream source.

Repository SourceNeeds Review
General

postgresql-core-schema

No summary provided by upstream source.

Repository SourceNeeds Review