Skip to content
Back to skills

Database Standard

ASecurity

Database design standards defining primary keys, foreign keys, audit fields, soft delete, junction tables. PostgreSQL style preferred, SQL lowercase without comments.

  • 666 stars
  • 0 votes
  • 1 copy
  • 18 views
  • Added February 8, 2026
databasessqldatabase

Security analysis

A100/100

Scanned February 12, 2026

npx -y skills add majiayu000/claude-skill-registry --skill database-standard --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Database Standard?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Database Standard
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-database-standard/badge)](https://www.skillsdirectory.com/skills/majiayu000-database-standard)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: database-standard
description: Database design standards defining primary keys, foreign keys, audit fields, soft delete, junction tables. PostgreSQL style preferred, SQL lowercase without comments.
---

## 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

```sql
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

```sql
create table user_role (
    user_id bigint not null references user(id),
    role_id bigint not null references role(id)
);
```

### Tree Table

```sql
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
);
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.