Use when diagnosing KWDB incidents from logs, metrics, or system evidence, especially crashes, OOM, slow SQL, restarts, and cluster-wide availability symptoms.
Design & media
KWDB Schema Design
Try itDesign KWDB schemas and generate DDL for relational, time-series, and mixed workloads. Covers: CREATE/ALTER/DROP TABLE, INDEX, VIEW, constraints, partitioning, retention, tags. Trigger keywords: KWDB, schema, table, index, time-series, sensor, IoT, metrics, TAGS, PRIMARY TAGS, RETENTIONS, primary key, foreign key, DDL. NOT for: DML queries, deployment, backup, performance tuning.
What it does
Design KWDB schemas and generate DDL for relational, time-series, and mixed workloads. Covers: CREATE/ALTER/DROP TABLE, INDEX, VIEW, constraints, partitioning, retention, tags. Trigger keywords: KWDB, schema, table, index, time-series, sensor, IoT, metrics, TAGS, PRIMARY TAGS, RETENTIONS, primary key, foreign key, DDL. NOT for: DML queries, deployment, backup, performance tuning.
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 rulesreferences/disambiguation.md- Clarifying questionsreferences/_scope.md- Skill boundaries (IN/OUT of scope)references/_examples.md- Complete dialogue examplesreferences/_contributing.md- How to add new referencesreferences/_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 TABLEreferences/index-ddl-ref.md- CREATE/DROP INDEXreferences/constraint-ref.md- CHECK, UNIQUE, FOREIGN KEY
Tier 3 (Medium-Frequency DDL) - Read when needed:
references/view-ref.md- Views and Materialized Viewsreferences/sequence-ref.md- Sequences and auto-incrementreferences/partitioning-ref.md- LIST, RANGE, HASH partitioningreferences/retention-ref.md- Time-series retention policies
Tier 4 (Low-Frequency DDL) - Only when explicitly requested:
references/trigger-ref.md- Triggersreferences/procedure-ref.md- Stored procedures and functionsreferences/database-ref.md- Database and schema operationsreferences/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
| Category | Operations |
|---|---|
| Tables | CREATE TABLE, ALTER TABLE, DROP TABLE |
| Indexes | CREATE INDEX, ALTER INDEX, DROP INDEX |
| Constraints | PRIMARY KEY, UNIQUE, CHECK, FOREIGN KEY |
| Views | CREATE VIEW, DROP VIEW |
| Materialized Views | CREATE MATERIALIZED VIEW, REFRESH, DROP |
| Sequences | CREATE SEQUENCE, nextval(), setval() |
| Time-Series | Tags, Primary Tags, Retention |
| Partitioning | LIST, 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 TABLEto verify syntaxSHOW COLUMNSto verify structureSHOW INDEXto 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
Convert natural language queries to KWDB SQL for time series data, relational data and cross-model analysis. Use this skill whenever users ask to query KWDB databases, write SQL for KWDB, or convert natural language to KWDB-specific SQL syntax. Supports: CREATE DATABASE/TABLE, downsampling, interpolation, latest value queries, aggregation analysis, cross-model queries, window/session/event analysis.
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.
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.
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).
Run KaiwuDB inspection and health-check tasks. Use this skill for database health checks, metrics collection, anomaly detection, and inspection report generation.