设计与多媒体

KWDB Schema Design

试用

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.

它能做什么

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.

技能文档

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

相关技能

Use when diagnosing KWDB incidents from logs, metrics, or system evidence, especially crashes, OOM, slow SQL, restarts, and cluster-wide availability symptoms.

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.

10 次安装

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.

12 次安装