nosql-expert by davila7/claude-code-templates
npx skills add https://github.com/davila7/claude-code-templates --skill nosql-expert此技能为分布式宽列与键值存储(特指 Apache Cassandra 和 Amazon DynamoDB)提供专业的思维模型和设计模式。
与 SQL(您需要为数据实体建模)或文档存储(如 MongoDB)不同,这些分布式系统要求您首先为查询建模。
| 特性 | SQL(关系型) | 分布式 NoSQL(Cassandra/DynamoDB) |
|---|---|---|
| 数据建模 | 为实体 + 关系建模 | 为查询(访问模式)建模 |
| 连接 | 在读取时进行,CPU 密集型 | 在写入时预计算(反规范化) |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 昂贵(最小化重复) |
| 廉价(为读取速度而重复数据) |
| 一致性 | ACID(强一致性) | BASE(最终一致性) / 可调一致性 |
| 可扩展性 | 垂直扩展(更大的机器) | 水平扩展(更多节点/分片) |
黄金法则: 在 SQL 中,您设计数据模型以回答任何查询。在 NoSQL 中,您设计数据模型以高效地回答特定查询。
通常,您无法在不进行迁移或创建新表/索引的情况下"稍后添加查询"。
流程:
数据根据分区键分布到物理节点上。
status="active" 或 gender="m")会导致热点分区,将吞吐量限制在单个节点的容量内。在分区内部,数据根据聚类键或排序键在磁盘上排序。
WHERE user_id=X AND date > Y)。主要用途:DynamoDB(但概念也适用于其他地方)
将多种实体类型存储在一个表中,以实现预连接的读取。
| PK(分区) | SK(排序) | 数据字段... |
|---|---|---|
USER#123 | PROFILE | { name: "Ian", email: "..." } |
USER#123 | ORDER#998 | { total: 50.00, status: "shipped" } |
USER#123 | ORDER#999 | { total: 12.00, status: "pending" } |
PK="USER#123"不要害怕将相同的数据存储在多个表中,以服务于不同的查询模式。
users_by_id(PK:uuid)users_by_email(PK:email)权衡:您必须管理跨表的数据一致性(通常使用最终一致性或批量写入)。
((分区键), 聚类列)JOIN 或 GROUP BY。在单独的计数器表中预计算聚合。ALLOW FILTERING: 如果在生产环境中看到此语句,说明您的数据模型是错误的。它意味着对整个集群进行扫描。在最终确定 NoSQL 模式之前:
USER#123#2024-01)。❌ 分散-聚集: 查询所有分区以查找一个项目(扫描)。
❌ 热点键: 将所有"星期一"的数据放入一个分区。
❌ 关系型建模: 创建 Author 和 Book 表并尝试在代码中连接它们。(相反,应将书籍摘要嵌入作者记录,或将作者信息复制到书籍记录中)。
每周安装数
138
代码仓库
GitHub 星标数
23.4K
首次出现
2026年1月25日
安全审计
安装于
claude-code120
opencode117
gemini-cli110
cursor109
antigravity104
codex104
This skill provides professional mental models and design patterns for distributed wide-column and key-value stores (specifically Apache Cassandra and Amazon DynamoDB).
Unlike SQL (where you model data entities), or document stores (like MongoDB), these distributed systems require you to model your queries first.
| Feature | SQL (Relational) | Distributed NoSQL (Cassandra/DynamoDB) |
|---|---|---|
| Data modeling | Model Entities + Relationships | Model Queries (Access Patterns) |
| Joins | CPU-intensive, at read time | Pre-computed (Denormalized) at write time |
| Storage cost | Expensive (minimize duplication) | Cheap (duplicate data for read speed) |
| Consistency | ACID (Strong) | BASE (Eventual) / Tunable |
| Scalability | Vertical (Bigger machine) | Horizontal (More nodes/shards) |
The Golden Rule: In SQL, you design the data model to answer any query. In NoSQL, you design the data model to answer specific queries efficiently.
You typically cannot "add a query later" without migration or creating a new table/index.
Process:
Data is distributed across physical nodes based on the Partition Key (PK).
status="active" or gender="m") creates Hot Partitions , limiting throughput to a single node's capacity.Within a partition, data is sorted on disk by the Clustering Key (Cassandra) or Sort Key (DynamoDB).
WHERE user_id=X AND date > Y).Primary use: DynamoDB (but concepts apply elsewhere)
Storing multiple entity types in one table to enable pre-joined reads.
| PK (Partition) | SK (Sort) | Data Fields... |
|---|---|---|
USER#123 | PROFILE | { name: "Ian", email: "..." } |
USER#123 | ORDER#998 | { total: 50.00, status: "shipped" } |
USER#123 | ORDER#999 |
PK="USER#123"Don't be afraid to store the same data in multiple tables to serve different query patterns.
users_by_id (PK: uuid)users_by_email (PK: email)Trade-off: You must manage data consistency across tables (often using eventual consistency or batch writes).
((Partition Key), Clustering Columns)JOIN or GROUP BY. Pre-calculate aggregates in a separate counter table.ALLOW FILTERING: If you see this in production, your data model is wrong. It implies a full cluster scan.Before finalizing your NoSQL schema:
USER#123#2024-01).❌ Scatter-Gather: Querying all partitions to find one item (Scan). ❌ Hot Keys: Putting all "Monday" data into one partition. ❌ Relational Modeling: Creating Author and Book tables and trying to join them in code. (Instead, embed Book summaries in Author, or duplicate Author info in Books).
Weekly Installs
138
Repository
GitHub Stars
23.4K
First Seen
Jan 25, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
claude-code120
opencode117
gemini-cli110
cursor109
antigravity104
codex104
Supabase Postgres 最佳实践指南 - 8大类别性能优化规则与SQL示例
73,500 周安装
Swift Testing异步代码测试指南:axiom-testing-async使用模式与迁移教程
156 周安装
iOS Apple Intelligence 路由器使用指南 - Foundation Models 与 AI 方法分流
157 周安装
ByteRover CLI - 上下文工程平台,为AI编码智能体自动管理项目知识库
154 周安装
嵌入式系统开发指南:RTOS、裸机固件、嵌入式Linux与微控制器编程实战
155 周安装
Markdown转EPUB转换器 - 专业电子书制作工具,支持代码高亮与表格样式
158 周安装
化学品安全与毒理学评估工具 | AI预测毒理学、ADMET分析、基因互作与监管安全数据整合
156 周安装
{ total: 12.00, status: "pending" } |