nosql-expert by sickn33/antigravity-awesome-skills
npx skills add https://github.com/sickn33/antigravity-awesome-skills --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 表并尝试在代码中连接它们。(相反,应将书籍摘要嵌入作者记录,或将作者信息复制到书籍记录中)。
每周安装量
204
代码仓库
GitHub 星标数
27.6K
首次出现
2026 年 1 月 24 日
安全审计
安装于
opencode174
gemini-cli170
claude-code167
antigravity154
codex150
cursor147
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
204
Repository
GitHub Stars
27.6K
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode174
gemini-cli170
claude-code167
antigravity154
codex150
cursor147
Supabase Postgres 最佳实践指南 - 8大类别性能优化规则与SQL示例
70,900 周安装
{ total: 12.00, status: "pending" } |