一键导入
data-ontologist
Polyglot persistence: when to use relational, graph, or document databases; integration patterns.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Polyglot persistence: when to use relational, graph, or document databases; integration patterns.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
{{ 𝚫𝚫𝚫 }} Rebuild roadmap-system.zip, the distributable snapshot of the roadmap tooling (scripts, HTML template, conventions reference, and every roadmap-touching skill, including this one).
{{ 𝛀𝛀𝛀 }} Create a project roadmap in the rich phase-array format — roadmaps.json as source of truth plus a PHASE task list and prose overview
{{ 𝛀𝛀𝛀 }} Recompute and synchronise roadmap task statuses across roadmaps.json and its projections, with optional codebase reconciliation
{{ 𝛀𝛀𝛀 }} Add a task to a rich-format project roadmap with correct ID, dependency wiring, and graph integrity — ID assignment, status computation, dependency edges in both directions, and no unconnected islands.
Git workflow: branch management, commit conventions, PR patterns, conflict resolution.
{{ 𝛀𝛀𝛀 }} Review a pull request and post it as a GitHub review
| name | Data Ontologist |
| description | Polyglot persistence: when to use relational, graph, or document databases; integration patterns. |
| when_to_use | When choosing a data store or storage pattern for new data, or reviewing a schema/migration — auto-loads on schema or migration files, or when the conversation raises 'which database', 'relational vs graph', or cross-store integration. |
| user-invocable | false |
| effort | high |
| paths | ["**/schema*","**/migrations/**"] |
| allowed-tools | ["Read","Glob","Grep"] |
Architectural guidance for using multiple database technologies together, with emphasis on PostgreSQL/Supabase (relational), Neo4j (graph), and MongoDB (document). Demonstrates when to use each database type and how to integrate them effectively.
Use this skill when:
Start with the graph. Optimise from there.
Most real-world domains are fundamentally about relationships. The graph is the truest representation of how entities connect. Start by thinking in nodes and edges — then decide where to persist based on access patterns and consistency needs.
Right database for right data concern
Don't force all data into one database type. Use:
Before choosing databases, model the domain as a graph:
// Step 1-3: Model the domain as a graph first
(:User)-[:MEMBER_OF {role: 'admin', since: date}]->(:Organisation)
(:User)-[:ENROLLED_IN {status: 'active'}]->(:Course)
(:Course)-[:REQUIRES]->(:Course)
(:User)-[:COMPLETED {score: 0.85}]->(:Module)
(:Module)-[:BELONGS_TO]->(:Course)
Then decide:
Transactional Data:
Structured Records:
Examples:
-- Users table
CREATE TABLE users (
id UUID PRIMARY KEY,
email TEXT UNIQUE NOT NULL,
name TEXT,
created_at TIMESTAMP DEFAULT NOW()
);
-- Orders table
CREATE TABLE orders (
id UUID PRIMARY KEY,
user_id UUID REFERENCES users(id),
total DECIMAL(10,2),
status TEXT,
created_at TIMESTAMP DEFAULT NOW()
);
Highly Connected Data:
Reason: Joins become expensive, recursive queries complex.
Rapidly Evolving Schemas:
Reason: Migrations expensive, rigid structure.
Relationships as Primary Concern:
Variable-Depth Traversals:
Examples:
// Social connections
(:User)-[:FOLLOWS]->(:User)
(:User)-[:BLOCKED]->(:User)
// Learning paths
(:Course)-[:REQUIRES]->(:Course)
(:User)-[:COMPLETED]->(:Course)
// Organizational structure
(:Person)-[:REPORTS_TO]->(:Person)
(:Person)-[:MEMBER_OF]->(:Team)
Simple Lookups:
Reason: Relational databases excel at indexed lookups.
Large Aggregations:
Reason: SQL aggregations and window functions more powerful.
Semi-Structured Data:
Nested/Embedded Data:
Flexible Schemas:
Examples:
// Blog post with embedded comments
{
_id: ObjectId("..."),
title: "Getting Started with SvelteKit",
slug: "getting-started-sveltekit",
author: { id: "user-123", name: "Alice" },
content: "...",
tags: ["svelte", "javascript", "tutorial"],
comments: [
{ id: "comment-1", userId: "user-456", text: "Great article!", createdAt: ISODate("2024-01-15") }
],
metadata: { views: 1250, readingTime: "5 min" },
publishedAt: ISODate("2024-01-10")
}
// Product with varying attributes
{
_id: ObjectId("..."),
name: "Laptop",
category: "electronics",
price: 999.99,
specs: { cpu: "Intel i7", ram: "16GB", storage: "512GB SSD", screen: "15.6 inch" }
}
// Different product type, different fields
{
_id: ObjectId("..."),
name: "T-Shirt",
category: "clothing",
price: 29.99,
sizes: ["S", "M", "L", "XL"],
colors: ["black", "white", "blue"],
material: "100% cotton"
}
Complex Transactions:
Reason: Relational databases better at multi-document transactions.
Relationship-Heavy Data:
Reason: Graph databases handle this natively.
Highly Normalized Data:
Reason: Relational databases enforce this better.
RELATIONSHIPS → Neo4j (Graph) — social connections, recommendations, dependency trees, path finding
STRUCTURED ENTITIES → PostgreSQL (Relational) — user accounts, financial transactions, inventory, orders
DOCUMENTS/CONTENT → MongoDB (Document) — blog posts, product catalogs, CMS content, API data storage
VERY STABLE → PostgreSQL — well-defined entities, clear field types, rare schema changes, strong typing needed
EVOLVING → MongoDB — prototyping phase, frequently adding fields, different record structures, flexible modeling
SCHEMA-OPTIONAL → Neo4j — relationships more important than structure, dynamic properties, graph structure evolves
BY KEY/ID → PostgreSQL or MongoDB — user by email, product by SKU, order by ID
BY TRAVERSAL → Neo4j — friends of friends, shortest path, recommendations
BY CONTENT/QUERY → MongoDB — full-text search, filtering nested documents, flexible queries on varying fields
ABSOLUTE → PostgreSQL — financial transactions, ACID guarantees, multi-step operations
EVENTUAL OKAY → MongoDB or Neo4j — content updates, social interactions, non-critical data
YES → MongoDB — posts with comments, orders with line items, documents with metadata
NO → PostgreSQL — flat entities, many-to-many relationships, normalized structure
Worked examples and mechanical detail, loaded only when needed:
Architecture is successful when: