← 返回
未分类 中文

Db Design

Deep database design workflow—entities and relationships, keys and constraints, normalization vs denormalization, indexing strategy, integrity, and operation...
深度数据库设计工作流——实体与关系、键与约束、规范化与反规范化、索引策略、完整性及运维...
codekungfu codekungfu 来源
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 522
下载
💾 0
安装
1
版本
#latest

概述

DB Design

Good OLTP design balances integrity, write paths, query patterns, and evolution—not “third normal form everywhere.”

When to Offer This Workflow

Trigger conditions:

  • Greenfield service schema or major new domain
  • Performance or integrity issues from ad-hoc tables
  • Multi-tenant isolation questions

Initial offer:

Use six stages: (1) domain & access patterns, (2) entities & relationships, (3) keys & constraints, (4) normalization trade-offs, (5) indexing & performance, (6) operations & evolution). Confirm RDBMS and scale expectations.


Stage 1: Domain & Access Patterns

Goal: List critical queries and writes: QPS, joins, filters, hot rows.

Exit condition: Top access paths ranked by business importance.


Stage 2: Entities & Relationships

Goal: ER model; cardinality; optional vs required relationships.

Practices

  • Clear table names; avoid opaque “data” blobs unless documented

Stage 3: Keys & Constraints

Goal: Primary keys (surrogate vs natural); foreign keys with explicit ON DELETE policy; unique constraints for business rules.

Multi-tenant

  • tenant_id on rows that need isolation; composite keys or indexes as appropriate

Stage 4: Normalization Trade-offs

Goal: Normalize to reduce update anomalies; denormalize read hotspots with documented trade-offs.


Stage 5: Indexing & Performance

Goal: Indexes serve real queries; watch write amplification and index bloat.


Stage 6: Operations & Evolution

Goal: Migration strategy (expand/contract); backup/restore; PII columns flagged.


Final Review Checklist

  • [ ] Access patterns drive schema
  • [ ] Keys, FKs, and constraints explicit
  • [ ] Multi-tenant isolation if applicable
  • [ ] Normalization decisions justified
  • [ ] Index plan aligned with queries
  • [ ] Migration and ops considerations noted

Tips for Effective Guidance

  • NULL semantics and defaults matter for bugs and migrations.
  • Pair with db-migrate for online schema changes.

Handling Deviations

  • Document stores: embed vs reference with consistency story.

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-03 05:39 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

dev-programming

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 686 📥 331,022
business-ops

抖音电商

codekungfu
该技能介绍如何通过抖音电商实现变现;当你计划从事或优化抖音电商时调用。
★ 2 📥 1,981
dev-programming

Mcporter

steipete
使用 mcporter CLI 直接列出、配置、认证及调用 MCP 服务器/工具(支持 HTTP 或 stdio),涵盖临时服务器、配置编辑及 CLI/类型生成功能。
★ 198 📥 68,216