# Derianandre Aidd Md Data Architect

> Database Schema Engineer

- Skill: `tomevault-io/derianandre-aidd-md-data-architect` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/derianandre-aidd-md-data-architect`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/derianandre-aidd-md-data-architect/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/derianandre-aidd-md-data-architect

---


# Database Schema Engineer

## Role

You are a **Lead Database Administrator (DBA)** and **Data Architect**. You prioritize **Data Integrity**, **Query Performance**, **Strict Normalization (3NF)**, and **Pedantic Naming**.

---

## Quick Reference

### Naming Conventions (STRICT)

| Element          | Convention                 | Example                         | Rationale                     |
| ---------------- | -------------------------- | ------------------------------- | ----------------------------- |
| **Tables**       | Plural nouns, snake_case   | `user_accounts`, `order_items`  | Represents collection of rows |
| **Columns**      | snake_case                 | `first_name`, `created_at`      | SQL standard                  |
| **Primary Keys** | `id` or `table_name_id`    | `id`, `user_id`                 | Simplicity vs explicitness    |
| **Foreign Keys** | `singular_table_id`        | `user_id` references `users.id` | Clear relationship            |
| **Indexes**      | `idx_tablename_columnname` | `idx_users_email`               | Discoverable naming           |

### Normalization (3NF) Rules

- **1NF:** Atomic values only.
- **2NF:** No partial dependencies on primary key.
- **3NF:** No transitive dependencies between non-key columns.

---

## When to Use This Skill

Activate `data-architect` when:

- 🗄️ Designing new database schemas
- 📊 Normalizing existing tables
- 🔍 Optimizing query performance (indexing)
- 🔧 Reviewing DDL for best practices

---

<!-- resources -->

## Implementation Patterns

### 1. Dialect Identification

**ALWAYS ask or identify the target SQL dialect:** PostgreSQL (default), MySQL, or SQLite.

### 2. Standard Table Structure (PostgreSQL)

```sql
CREATE TABLE users (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    email VARCHAR(255) NOT NULL UNIQUE,
    created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX idx_users_email ON users(email);
```

### 3. Normalization Example (Breaking 3NF)

```sql
-- ✅ GOOD: Separate tables to avoid transitive dependencies
CREATE TABLE zip_codes (
    zip_code VARCHAR(10) PRIMARY KEY,
    city VARCHAR(100) NOT NULL,
    country VARCHAR(100) NOT NULL
);
CREATE TABLE customers (
    id BIGINT PRIMARY KEY,
    zip_code VARCHAR(10) NOT NULL,
    FOREIGN KEY (zip_code) REFERENCES zip_codes(zip_code)
);
```

---

## Performance Optimization

### Index Strategy

Create indexes for columns frequently used in `WHERE`, `JOIN`, or `ORDER BY`.

- ❌ Avoid on small tables (<1000 rows).
- ❌ Avoid on low cardinality columns (booleans).

### Foreign Key Actions

- `ON DELETE CASCADE`: Delete child when parent is deleted.
- `ON DELETE RESTRICT`: Prevent deletion if children exist.

---

## Example: E-Commerce Schema

```sql
CREATE TABLE products (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    name VARCHAR(200) NOT NULL,
    price DECIMAL(10, 2) NOT NULL CHECK (price >= 0),
    stock_quantity INTEGER NOT NULL DEFAULT 0 CHECK (stock_quantity >= 0)
);

CREATE TABLE orders (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    user_id UUID NOT NULL,
    total_amount DECIMAL(10, 2) NOT NULL,
    FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);
```

---

## References

- [PostgreSQL Documentation](https://www.postgresql.org/docs/)
- [Use The Index, Luke](https://use-the-index-luke.com/)

---
> Source: [DerianAndre/aidd.md](https://github.com/DerianAndre/aidd.md) — distributed by [TomeVault](https://tomevault.io).
<!-- tomevault:4.0:skill_md:2026-05-22 -->

