Design & media

KWDB Schema Design

Try it

Design KWDB schemas and produce executable DDL for relational, time-series, and mixed workloads with validation steps.

What it does

Guides schema design for KWDB through a five-step workflow: classify workload type, gather requirements, design tables, generate DDL, and validate. Produces minimal, executable DDL covering tables, indexes, constraints, views, materialized views, sequences, partitioning, and time-series tags with retention. Results are organized into Intent, Workload Type, Assumptions, Design, DDL, and Validation sections. Enforces guardrails such as indexing foreign-key columns and using DECIMAL for monetary values.

When to use it

  • Designing a new KWDB table for IoT sensor readings
  • Adding indexes and constraints to an existing KWDB schema
  • Building a mixed relational and time-series schema
  • Setting up retention and partitioning on time-series tables

The skill document

ALWAYS invoke this skill via the Skill tool before designing any KWDB schema.

This applies even when:

  • Reference file contents appear in conversation context (from previous reads)
  • Session was restored from a compacted conversation
  • You believe you already know the KWDB syntax

Reading reference files directly ≠ Skill invocation. The Skill tool triggers the complete workflow (classify → gather requirements → design → DDL → validate) and ensures guardrails are followed. Skip this step = skip the workflow.

Tiered Reference Architecture

Tier 1 (Always Read) - Core rules, scope, and examples:

  • references/key-rules.md - Decision tree and core rules
  • references/disambiguation.md - Clarifying questions
  • references/_scope.md - Skill boundaries (IN/OUT of scope)
  • references/_examples.md - Complete dialogue examples
  • references/_contributing.md - How to add new references
  • references/_sections.md - Tier definitions and categories

Tier 2 (High-Frequency DDL) - Read when designing tables/indexes/constraints:

  • references/table-ddl-ref.md - CREATE/ALTER/DROP TABLE
  • references/index-ddl-ref.md - CREATE/DROP INDEX
  • references/constraint-ref.md - CHECK, UNIQUE, FOREIGN KEY

Tier 3 (Medium-Frequency DDL) - Read when needed:

  • references/view-ref.md - Views and Materialized Views
  • references/sequence-ref.md - Sequences and auto-increment
  • references/partitioning-ref.md - LIST, RANGE, HASH partitioning
  • references/retention-ref.md - Time-series retention policies

Tier 4 (Low-Frequency DDL) - Only when explicitly requested:

  • references/trigger-ref.md - Triggers
  • references/procedure-ref.md - Stored procedures and functions
  • references/database-ref.md - Database and schema operations
  • references/privilege-ref.md - User, role, and permission management

When to Activate

Should trigger (explicit KWDB):

  • "design a KWDB schema"
  • "write KWDB DDL"
  • "create a table/index/view in KWDB"
  • "KWDB schema for ..."
  • "KWDB CREATE TABLE"

Should trigger (implicit - schema keywords):

  • "create table" / "design table" / "table structure"
  • "add column" / "modify column" / "alter table"
  • "create index" / "add index" / "drop index"
  • "primary key" / "foreign key" / "constraints"
  • "schema design" / "database schema"

Should trigger (time-series keywords):

  • "sensor data" / "IoT" / "metrics" / "readings"
  • "time-series" / "time series" / "timestamp data"
  • "TAGS" / "PRIMARY TAGS" / "RETENTIONS"
  • "device data" / "monitoring data" / "logs"

Should trigger (relational keywords):

  • "users/orders/products" + "schema/table"
  • "entity" + "table"
  • "foreign key relationship"

Should trigger (financial/trading keywords):

  • "高频交易" / "HFT" / "行情" / "tick data"
  • "订单簿" / "order book" / "K线" / "kline"
  • "VWAP" / "成交量" / "价差" / "深度"
  • "stock" / "futures" / "期权" / "证券"

Should NOT trigger:

  • "SELECT ..." / "INSERT ..." / "UPDATE ..." (DML queries)
  • "how to query" / "optimize query" (query optimization)
  • Deployment, troubleshooting, migration questions
  • Backup/restore operations
  • "explain analyze" / "slow query" (performance tuning)
  • User/permission management (unless explicitly requested)

Supported DDL Operations

CategoryOperations
TablesCREATE TABLE, ALTER TABLE, DROP TABLE
IndexesCREATE INDEX, ALTER INDEX, DROP INDEX
ConstraintsPRIMARY KEY, UNIQUE, CHECK, FOREIGN KEY
ViewsCREATE VIEW, DROP VIEW
Materialized ViewsCREATE MATERIALIZED VIEW, REFRESH, DROP
SequencesCREATE SEQUENCE, nextval(), setval()
Time-SeriesTags, Primary Tags, Retention
PartitioningLIST, RANGE, HASH (relational), HASHPOINT (time-series)

Workflow

Step 1: Classify Workload Type

Request → RELATIONAL / TIME-SERIES / MIXED

Ask if unclear. Never skip this step.

Step 2: Gather Requirements

Use disambiguation.md to ask:

  • What data fields are needed
  • Primary key strategy
  • Query patterns (filter, group, join)
  • For time-series: retention needs

Step 3: Design Schema

Apply rules from key-rules.md and relevant tier-2/3 references:

  • Choose correct column types
  • Design primary keys
  • Add indexes only when needed
  • For time-series: design tags and retention

Step 4: Generate DDL

Output minimal, executable DDL:

  • Use correct KWDB syntax
  • Include NOT NULL where appropriate
  • Add comments for clarity

Step 5: Validate

Include validation step:

  • SHOW CREATE TABLE to verify syntax
  • SHOW COLUMNS to verify structure
  • SHOW INDEX to verify indexes

Output Format

## Intent
[Brief description of what the schema does]

## Workload Type
[relational / time-series / mixed]

## Assumptions
[Any assumptions made - retention, primary key strategy, etc.]

## Design
[Table structure with column types and rationale]

## DDL
```sql
-- minimal executable DDL

Validation

[How to verify the DDL works]


## Guardrails

1. **Never output DDL before classifying workload type**
2. **Never assume retention without stating it** (time-series)
3. **Never create speculative indexes** (label as optional)
4. **Prefer minimal schema** over comprehensive
5. **State all assumptions** when information is incomplete
6. **Validate DDL** before finishing
7. **FK columns must be indexed**
8. **Use appropriate types** (DECIMAL for money, not FLOAT)

## Error Handling

- If requirements unclear: ask clarifying questions first
- If DDL might be wrong: suggest validation steps
- If feature not supported: explain KWDB limitation
- If ambiguous request: classify workload type first

Related skills

Generate and edit Draw.io, Mermaid, and Excalidraw diagrams from natural language using a structured JSON spec.

by nssa.io1.0k installs47 stars

Find why your productivity system keeps failing, then apply the smallest fix — capacity math, bottleneck routing, durable local notes.

by Iván855 installs69 stars

Stores durable facts in a categorized, plain-markdown vault on disk, alongside your agent's built-in memory.

by Iván559 installs18 stars

Run Git operations — commits, branches, merges, rebases, conflict resolution, and recovery — with safety rules enforced.

by Iván535 installs31 stars

Fetch raw ad creative, app, ranking, and revenue data from AdMapix as structured JSON.

by fly0pants4.3k installs296 stars

More from kwdb

Browse all skills

Generate KWDB SQL from natural language for time series, relational, and cross-model queries.

by kwdb10 installs

Triggered when the user wants to install or deploy KaiwuDB (kwdb, kaiwudb). Helps users complete script-based deployment of KaiwuDB clusters, including configuration file modification, installation command execution, cluster initialization, and status checks.

by kwdb10 installs

Run KaiwuDB inspection and health-check tasks. Use this skill for database health checks, metrics collection, anomaly detection, and inspection report generation.

by kwdb12 installs

Optimize SQL query performance for KaiwuDB time-series and relational engines. Covers: EXPLAIN analysis, time-series optimization, pagination, cross-model queries. Trigger keywords: optimize query, slow query, explain, execution plan, performance, 性能, 查询优化. NOT for: DDL, schema design, deployment, DML writes.

by kwdb

Automated heterogeneous database migration skill for KaiwuDB / KWDB via KDTS REST API. Use this skill whenever the user mentions: - heterogeneous migration, cross-database migration, or data migration to KaiwuDB / KWDB - KDTS, migration tool, or data transfer between different databases - Specific source databases: MySQL, Oracle, PostgreSQL, SQL Server, ClickHouse, TDengine, InfluxDB, OpenTSDB, MongoDB, FTP, HDFS - Migration operations: create migration task, configure data source, test connection, import data, sync schema, batch migration - Migration management: query task status, view migration progress, check logs, kill migration, export/import config - Data type mapping, table structure sync, DDL generation, schema validation Even if the user does not explicitly say "migration", trigger this skill when they ask to transfer or sync data between databases with different engines.

by kwdb

Automates end-to-end anomaly detection for time-series data stored in KaiwuDB / KWDB. Use this skill whenever the user mentions: - anomaly detection, outliers, or unusual patterns in KWDB / KaiwuDB time-series data - inspecting sensor metrics, IoT telemetry, or monitoring data for spikes, dips, or drift - "find anomalies", "detect outliers", "3-sigma check", "STL decomposition", or "time-series anomaly" - analyzing historical trends, abnormal points, or data quality issues in TS tables Even if the user does not explicitly say "anomaly", trigger this skill when they ask to inspect, validate, or flag unusual values in time-series columns (integer, float, double).

by kwdb