数据库模式设计与审查
database-schema-designer
设计或审查数据库模式(schema)。在数据建模、创建表/集合、选择 SQL 还是 NoSQL、模式规范化、规划索引、编写迁移脚本,或审计数据库完整性与性能时使用。
- License 许可
- MIT
- 所属仓库
- carterdea/dots
- 最近更新
- 2026-11-15
- Stars
- ★ 4
- Forks
- 3
01 前言 Front Matter
- name
- database-schema-designer
- license
- MIT
- description
- Design or review database schemas. Use when modeling data, creating tables/collections, choosing SQL vs NoSQL, normalizing schemas, planning indexes, writing migrations, or auditing database integrity and performance.
02 资源文件 64
- 资产文件assets/templates/migration-template.sql1.9 KB
- 参考文档docx-js.md16.1 KB
- 许可证LICENSE1.0 KB
- 许可证LICENSE.txt1.4 KB
- 参考文档ooxml.md23.0 KB
- 参考文档ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd1.9 KB
- 参考文档ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd2.5 KB
- 参考文档ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd2.8 KB
- 参考文档ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd1.3 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd73.2 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd6.8 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd50.1 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd624 B
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd148.5 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd1.2 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd8.7 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd14.4 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd81.7 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd1.2 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd7.2 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd6.2 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd1.2 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd880 B
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd2.5 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd3.4 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd7.3 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd22.8 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd1.3 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd236.6 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd25.5 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd24.7 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd535 B
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd5.6 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd3.9 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd167.4 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd4.5 KB
- 参考文档ooxml/schemas/mce/mc.xsd3.1 KB
- 参考文档ooxml/schemas/microsoft/wml-2010.xsd25.9 KB
- 参考文档ooxml/schemas/microsoft/wml-2012.xsd3.7 KB
- 参考文档ooxml/schemas/microsoft/wml-2018.xsd901 B
- 参考文档ooxml/schemas/microsoft/wml-cex-2018.xsd1.7 KB
- 参考文档ooxml/schemas/microsoft/wml-cid-2016.xsd1002 B
- 参考文档ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd600 B
- 参考文档ooxml/schemas/microsoft/wml-symex-2015.xsd745 B
- 脚本ooxml/scripts/pack.py5.5 KB
- 脚本ooxml/scripts/unpack.py1.0 KB
- 脚本ooxml/scripts/validate.py1.9 KB
- 脚本ooxml/scripts/validation/__init__.py336 B
- 脚本ooxml/scripts/validation/base.py39.0 KB
- 脚本ooxml/scripts/validation/docx.py9.8 KB
- 脚本ooxml/scripts/validation/pptx.py12.0 KB
- 脚本ooxml/scripts/validation/redlining.py10.9 KB
- 参考文档README.md1.2 KB
- 参考文档references/nosql-design.md2.5 KB
- 参考文档references/schema-design-checklist.md3.4 KB
- 参考文档references/sql-design.md5.1 KB
- 脚本scripts/__init__.py65 B
- 脚本scripts/document.py49.2 KB
- 脚本scripts/templates/comments.xml2.6 KB
- 脚本scripts/templates/commentsExtended.xml2.6 KB
- 脚本scripts/templates/commentsExtensible.xml2.7 KB
- 脚本scripts/templates/commentsIds.xml2.6 KB
- 脚本scripts/templates/people.xml147 B
- 脚本scripts/utilities.py13.4 KB
03 SKILL.md 正文
Database Schema Designer
Design database schemas from domain requirements and access patterns. The main job is not to emit tables quickly; it is to produce a schema that preserves data integrity, fits the workload, and can evolve safely.
References
Load only the reference that matches the branch you are in:
- SQL schema design, normalization, data types, constraints, relationships, indexes, migrations, and performance:
references/sql-design.md - MongoDB / document modeling, embed-vs-reference decisions, and NoSQL indexes:
references/nosql-design.md - Full review and deployment checklist:
references/schema-design-checklist.md - Reversible SQL migration skeleton:
assets/templates/migration-template.sql
Dialect Policy
- Ask for the target database when syntax matters.
- Default examples to PostgreSQL-compatible SQL unless the request names another dialect.
- Translate identity columns, timestamp defaults, indexes, JSON types, generated columns, and migration syntax to the chosen dialect before presenting final DDL.
- Do not emit MySQL-only syntax (
AUTO_INCREMENT, inlineINDEX,ON UPDATE CURRENT_TIMESTAMP,ALTER TABLE ... MODIFY) for PostgreSQL or SQLite requests. - If the request names MongoDB or document storage, switch to the NoSQL branch and model around access patterns.
Workflow
1. Gather The Shape
Extract or ask for:
- Entities or collections.
- Relationships and cardinality.
- Read/write access patterns.
- Scale hints, tenancy, and retention requirements.
- Database engine and dialect.
- Existing schema or migration constraints, when this is a review or evolution task.
Completion criterion: every table/collection you propose maps to a domain concept or named access pattern, and every unknown that affects syntax or integrity is either resolved or listed as an assumption.
2. Choose The Storage Model
Use SQL by default for transactional domains with relationships, constraints, joins, reporting correctness, or evolving business rules.
Use NoSQL/document modeling only when access patterns are known and documents are usually read/written together, or when the user explicitly asks for it.
Completion criterion: the output states why SQL or NoSQL fits the workload, and names the tradeoff that would make the other choice better.
3. Design The Schema
For SQL, load references/sql-design.md. Design from the domain outward:
- Normalize to 3NF first unless a specific read path justifies denormalization.
- Define primary keys, foreign keys,
ON DELETEbehavior,NOT NULL,UNIQUE, andCHECKconstraints. - Choose dialect-appropriate data types.
- Add timestamps only where lifecycle tracking is useful.
For NoSQL, load references/nosql-design.md. Design around access patterns:
- Choose embedded documents when data is read together and bounded.
- Use references when child sets are large, independently updated, or shared.
- Keep document size and update frequency explicit.
Completion criterion: every relationship has an ownership/cardinality decision, every required field has an integrity rule, and every intentional duplicate/denormalized value names the query it serves.
4. Plan Indexes From Queries
Indexes follow access patterns, not vibes. List the query patterns first, then add indexes for:
- Foreign keys and joins.
- High-frequency
WHERE,ORDER BY, and uniqueness checks. - Composite queries with column order matched to the query.
- Partial, text, or geospatial indexes only when the query shape calls for them.
Completion criterion: every non-primary index has a named query/use case, and the output calls out write-cost or over-indexing risks.
5. Plan Migration Safety
For new schemas, provide DDL and initial indexes.
For schema changes, make migrations reversible and deployment-aware:
- Add nullable columns before enforcing
NOT NULL. - Backfill separately from schema changes for large tables.
- Dual-write/read-compatibly for renames.
- Avoid long locks; use dialect-safe concurrent index patterns where needed.
Completion criterion: migration output includes an UP path, a DOWN path or explicit irreversible-risk note, and the rollout order needed to keep existing app versions working.
6. Review Before Final
Before responding, load references/schema-design-checklist.md for any substantial design or review task.
Completion criterion: final output includes the relevant checklist results or a concise "review notes" section covering primary keys, relationships, constraints, indexes, migrations, and unresolved risks.
Output Shape
Use the smallest useful structure for the request:
- New schema: assumptions, schema DDL or document shapes, indexes, migration notes, review notes.
- Schema review: findings ordered by severity, specific table/field/index references, fixes, and migration risk.
- Index request: access patterns, proposed indexes, query examples, tradeoffs.
- Migration request: rollout plan,
UP,DOWN, backfill/dual-write notes, lock risk. - SQL vs NoSQL decision: recommendation, access-pattern reasoning, rejected alternative, risk.
Core Rules
- Model the domain, not the UI.
- Prefer database-enforced integrity over app-only conventions.
- Use
DECIMAL/exact numeric types for money; never use floating point for currency. - Index foreign keys unless the dialect already does and you have verified that behavior.
- Treat
SELECT *, missing foreign keys, unbounded documents, and non-reversible migrations as review findings. - Do not invent production scale, access patterns, or business rules. State assumptions when the prompt omits them.
04 同仓库更多 Skills
test-audit
Writing/changing/reviewing/sweeping tests: reject duplicate or implementation-coupled proof; remove test-only production seams.
untangle-codebase
Untangle a whole codebase in one pass, so agents working in it read less per change, break less without noticing, and debug faster.
write-swift
How to write modern Swift well — modeling with value types, Swift 6 data-race safety and approachable concurrency (@concurrent, main-actor-by-default, actors, task groups), protocols and generics (some vs any), API design, performance and ARC, Swift Testing, macros, and the modern language features agents don't know about yet. Use when writing, reviewing, or migrating Swift, or when a concurrency error, a hang, a data race, a retain cycle, or a performance problem needs fixing.
stageshow
Build faux product UI that looks like a real product, as a still illustration or an animated demo with a cursor. Browser and app windows, dashboards, phones, notifications, terminals, bento grids and cursor walkthroughs, framed, masked and cropped the way a marketing page, feature card or docs hero needs them. Use whenever someone wants a fake or mocked UI, a product demo or walkthrough animation, a hero or feature-card illustration of an app, a product shot in the style of a polished marketing site, or an animated cursor doing things in an interface, even if they never say "faux UI". React and plain CSS.
review-animations
Reviews animation and motion code against a high craft bar derived from Emil Kowalski's design engineering philosophy. Default to flagging; approval is earned.
remove-animations
Find the animations an interface doesn't need and remove them — motion on keyboard actions, high-frequency surfaces, functional data, and decoration with no purpose — then clean up what they leave behind. Edits code, but only to subtract; it never adds or retunes motion. Use when the user says the app "feels slow", "has too much animation", "feels over-animated", wants to "tone down the motion", or asks what animations to remove. For finding places that should animate, use find-animation-opportunities; for fixing animations that should stay, use improve-animations or review-animations.