Agent skill
database-standard
Database design standards defining primary keys, foreign keys, audit fields, soft delete, junction tables. PostgreSQL style preferred, SQL lowercase without comments.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/database-standard
SKILL.md
Database Preferences
- Forbidden: MySQL
- Recommended: PostgreSQL or other modern databases
- Required: Foreign key constraints for data integrity
SQL Code Style
- All lowercase
- SQL files have no comments
Primary Key Standard
| Field | Type | Description |
|---|---|---|
id |
bigint | Primary key, required for all regular tables |
Audit Fields
All tables except junction tables MUST include:
| Field | Full Name | Type | Default | Description |
|---|---|---|---|---|
crd |
create row datetime | timestamp | current_timestamp | Row creation time, timezone-independent |
mrd |
modify row datetime | timestamp | null | Last modification time, timezone-independent, nullable |
rlv |
row lock version | integer | 0 | Optimistic lock version |
Soft Delete Field
| Field | Full Name | Type | Default | Description |
|---|---|---|---|---|
ldf |
logic delete field | timestamp | null | Soft delete time, timezone-independent, null means active |
Junction Table Standard
Tables linking two entities:
- No primary key
- No audit fields
- Only foreign key IDs from both tables
Tree Structure
Tables with upward lookup (e.g., address) use pid for parent link:
| Field | Type | Description |
|---|---|---|
pid |
bigint | Parent primary key, nullable |
Examples
Regular Table
create table user (
id bigint primary key,
name varchar(255) not null,
email varchar(255),
ldf timestamp,
crd timestamp not null default current_timestamp,
mrd timestamp,
rlv integer not null default 0
);
Junction Table
create table user_role (
user_id bigint not null references user(id),
role_id bigint not null references role(id)
);
Tree Table
create table address (
id bigint primary key,
pid bigint references address(id),
name varchar(255) not null,
crd timestamp not null default current_timestamp,
mrd timestamp,
rlv integer not null default 0
);
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?