data-model-creation by tencentcloudbase/skills
npx skills add https://github.com/tencentcloudbase/skills --skill data-model-creation这是一个可选的数据库高级建模工具,适用于复杂的数据表设计。大多数简单的建表操作应直接使用 relational-database-tool 配合 SQL 语句。
仅在以下特定需求时使用此技能:
对于大多数情况,请使用 relational-database-tool 技能:
请勿用于:
⚠️ 注意:这是可选的。对于简单任务,请跳过此步骤并直接使用 relational-database-tool。
当您确实需要使用这种高级建模方法时:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
* 业务分析阶段:分析用户需求,识别核心实体和关系
* Mermaid 建模阶段:遵循生成规则创建 mermaid classDiagram
* 模型验证阶段:检查完整性、一致性和正确性
2. 严格应用生成规则(使用此工具时)
* 使用正确的类型映射(string、number、boolean、x-enum 等)
* 将中文转换为英文命名(类名使用 PascalCase,字段名使用 camelCase)
* 在需要时定义 required()、unique()、display_field() 函数
* 使用带有字段名的正确关系表示法
3. 正确使用工具(仅在选择此方法时)
* 仅针对复杂的多实体业务需求调用数据模型创建工具
* 使用 `mermaidDiagram` 参数并传入完整的 mermaid classDiagram 代码
* 初始设置 `publish` 为 false,先创建再单独发布
* 为新模型或现有模型选择合适的 `updateMode`
大多数数据库任务 → relational-database-tool 技能
仅复杂建模 → 此技能 (data-model-creation)
对于大多数数据库建表任务,请直接使用 relational-database-tool 技能:
CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(255))ALTER TABLE users ADD COLUMN email VARCHAR(255)INSERT、UPDATE、SELECT、DELETE仅在以下情况使用此高级 Mermaid 建模方法:
此规则适用于复杂建模场景,但大多数开发应使用直接 SQL 执行。
作为数据建模专家和软件开发高级架构师,您精通 Mermaid。您的主要任务是根据用户描述,遵循以下详细规则,以 mermaid classDiagram 格式提供模型结构:
| 业务字段 | type |
|---|---|
| 文本 | string |
| 数字 | number |
| 布尔值 | boolean |
| 枚举 | x-enum |
| 邮箱 | |
| 电话 | phone |
| URL | url |
| 文件 | x-file |
| 图片 | x-image |
| 富文本 | x-rtf |
| 地区 | x-area-code |
| 时间 | time |
| 日期 | date |
| 日期时间 | datetime |
| 对象 | object |
| 数组 | string[] |
| 位置 | x-location |
命名规范:将中文描述转换为英文命名(枚举值除外)。类名使用 PascalCase,字段名使用 camelCase。
字段可见性:字段使用默认可见性,不添加 "+" 或 "-"。
数组类型:当描述中包含数组类型时,使用特定的数组格式,如 string[]、number[]、x-rtf[] 等。
中国行政区划:当涉及"省/市/区"等中国行政区划时,使用 x-area-code 字段类型。
必填字段:当描述中明确提到必填字段时,定义一个 required() 无参函数,返回值为必填字段名的字符串数组,例如 required() ["name", "age"]。默认情况下,字段不是必填的。
唯一字段:当描述中明确提到唯一字段时,定义一个 unique() 无参函数,返回值为唯一字段名的字符串数组,例如 unique() ["name", "age"]。默认情况下,字段不是唯一的。
默认值:当描述中明确要求字段默认值时,在字段定义后使用 "= 默认值" 格式,例如 age: number = 0。默认情况下,字段没有默认值。
字段描述:对于用户描述中的每个字段定义,在定义行末尾使用 <<描述>> 格式,例如 name: string <<姓名>>。
显示字段:每个实体类在被引用时应有一个用于显示的字段。通常是一个人类可读的名称或唯一标识符。定义 display_field() 无参函数,返回值是一个表示主要显示字段的字段名,例如 display_field() "name" 表示主要显示字段是 name。否则,默认为数据模型的隐式 _id。
类注释:在所有类定义完成后,使用 note 描述类名。首先使用 "%% 类命名" 锚定区域,然后为每个类提供中文表名。
关系:当描述中包含关系时,关系标签 LabelText 不应使用原始语义,而应使用关系字段名。例如,A "n" <-- "1" B: field1 表示 A 与 B 存在多对一关系,数据存在于 A 的 field1 字段中。具体请参考示例。
命名:Mermaid 中的字段名和描述应简洁且表达准确。
复杂度控制:除非用户要求,否则控制复杂度,例如类数量不应超过 5 个,控制字段复杂度。
classDiagram
class Student {
name: string <<Name>>
age: number = 18 <<Age>>
gender: x-enum = "Male" <<Gender>>
classId: string <<Class ID>>
identityId: string <<Identity ID>>
course: Course[] <<Courses>>
required() ["name"]
unique() ["name"]
enum_gender() ["Male", "Female"]
display_field() "name"
}
class Class {
className: string <<Class Name>>
display_field() "className"
}
class Course {
name: string <<Course Name>>
students: Student[] <<Students>>
display_field() "name"
}
class Identity {
number: string <<ID Number>>
display_field() "number"
}
%% Relationships
Student "1" --> "1" Identity : studentId
Student "n" --> "1" Class : student2class
Student "n" --> "m" Course : course
Student "n" <-- "m" Course : students
%% Class naming
note for Student "Student Model"
note for Class "Class Model"
note for Course "Course Model"
note for Identity "Identity Model"
string → VARCHAR/TEXTnumber → INT/BIGINT/DECIMALboolean → BOOLEAN/TINYINTdate → DATEdatetime → DATETIMEtime → TIMEx-enum → ENUM 类型x-file/x-image → 文件路径存储x-rtf → LONGTEXT 富文本x-area-code → 地区代码x-location → 地理位置坐标email/phone/url → 带验证的 VARCHARmanageSqlDatabase(action="runStatement") 配合 CREATE TABLEmanageSqlDatabase(action="runStatement") 配合 ALTER TABLEquerySqlDatabase(action="runQuery")mermaidDiagram:完整的 mermaid classDiagram 代码publish:是否立即发布模型(建议默认设为 false,先创建再发布)updateMode:创建新模型或更新现有模型classDiagram
class User {
username: string <<Username>>
email: email <<Email>>
password: string <<Password>>
avatar: x-image <<Avatar>>
status: x-enum = "active" <<Status>>
required() ["username", "email"]
unique() ["username", "email"]
enum_status() ["active", "inactive", "banned"]
display_field() "username"
}
classDiagram
class Product {
name: string <<Product Name>>
price: number <<Price>>
description: x-rtf <<Product Description>>
images: x-image[] <<Product Images>>
category: string <<Category>>
stock: number = 0 <<Stock>>
required() ["name", "price"]
display_field() "name"
}
class Order {
orderNo: string <<Order Number>>
totalAmount: number <<Total Amount>>
status: x-enum = "pending" <<Order Status>>
createTime: datetime <<Create Time>>
required() ["orderNo", "totalAmount"]
unique() ["orderNo"]
enum_status() ["pending", "paid", "shipped", "completed", "cancelled"]
display_field() "orderNo"
}
classDiagram
class Article {
title: string <<Title>>
content: x-rtf <<Content>>
author: string <<Author>>
publishTime: datetime <<Publish Time>>
status: x-enum = "draft" <<Status>>
tags: string[] <<Tags>>
required() ["title", "content", "author"]
enum_status() ["draft", "published", "archived"]
display_field() "title"
}
这些规则将指导 AI 代理在数据建模过程中生成高质量、符合业务需求的数据模型。
每周安装量
560
代码仓库
GitHub 星标数
39
首次出现
2026 年 1 月 22 日
安全审计
安装于
codex490
opencode490
gemini-cli481
github-copilot468
kimi-cli460
amp457
This is an OPTIONAL advanced modeling tool for complex database design. Most simple table creation should use relational-database-tool directly with SQL statements.
ONLY use this skill when you specifically need:
For most cases, userelational-database-tool skill instead:
Do NOT use for:
⚠️ NOTE: This is OPTIONAL. For simple tasks, skip this and userelational-database-tool directly.
When you do use this advanced modeling approach:
Optional modeling workflow (only when complexity justifies it)
Apply generation rules strictly (when using this tool)
Use tools correctly (only when you choose this approach)
mermaidDiagram parameter with complete mermaid classDiagram codepublish to false initially, create then publish separatelyupdateMode for new or existing modelsMost Database Tasks →relational-database-tool skill
Complex Modeling Only → This skill (data-model-creation)
For most database table creation tasks, userelational-database-tool skill directly:
CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(255))ALTER TABLE users ADD COLUMN email VARCHAR(255)INSERT, UPDATE, SELECT, DELETEOnly use this advanced Mermaid modeling approach when:
This rule exists for complex modeling scenarios, but most development should use direct SQL execution.
As an expert in data modeling and a senior architect in software development, you are proficient in Mermaid. Your main task is to provide model structures in mermaid classDiagram format based on user descriptions, following the detailed rules below:
| Business Field | type |
|---|---|
| Text | string |
| Number | number |
| Boolean | boolean |
| Enum | x-enum |
| Phone | phone |
| URL | url |
| File | x-file |
| Image | x-image |
| Rich Text | x-rtf |
| Region | x-area-code |
| Time | time |
| Date | date |
| DateTime | datetime |
| Object | object |
| Array |
Naming Convention : Convert Chinese descriptions to English naming (except enum values). Use PascalCase for class names, camelCase for field names.
Field Visibility : Use default visibility for fields, do not add "+" or "-".
Array Types : When descriptions include array types, use specific array formats such as string[], number[], x-rtf[], etc.
Chinese Administrative Regions : When involving Chinese administrative regions like "province/city/district", use x-area-code field type.
Required Fields : When descriptions explicitly mention required fields, define a required() parameterless function, return value as string array of required field names, e.g., required() ["name", "age"]. By default, fields are not required.
Unique Fields : When descriptions explicitly mention unique fields, define a unique() parameterless function, return value as string array of unique field names, e.g., unique() ["name", "age"]. By default, fields are not unique.
Default Values : When descriptions explicitly require field default values, use "= default value" format after field definition, e.g., age: number = 0. By default, fields have no default values.
classDiagram
class Student {
name: string <<Name>>
age: number = 18 <<Age>>
gender: x-enum = "Male" <<Gender>>
classId: string <<Class ID>>
identityId: string <<Identity ID>>
course: Course[] <<Courses>>
required() ["name"]
unique() ["name"]
enum_gender() ["Male", "Female"]
display_field() "name"
}
class Class {
className: string <<Class Name>>
display_field() "className"
}
class Course {
name: string <<Course Name>>
students: Student[] <<Students>>
display_field() "name"
}
class Identity {
number: string <<ID Number>>
display_field() "number"
}
%% Relationships
Student "1" --> "1" Identity : studentId
Student "n" --> "1" Class : student2class
Student "n" --> "m" Course : course
Student "n" <-- "m" Course : students
%% Class naming
note for Student "Student Model"
note for Class "Class Model"
note for Course "Course Model"
note for Identity "Identity Model"
string → VARCHAR/TEXTnumber → INT/BIGINT/DECIMALboolean → BOOLEAN/TINYINTdate → DATEdatetime → DATETIMEtime → TIMEx-enum → ENUM typex-file/x-image → File path storagex-rtf → LONGTEXT rich textx-area-code → Region codex-location → Geographic location coordinatesemail/phone/url → VARCHAR with validationmanageSqlDatabase(action="runStatement") with CREATE TABLEmanageSqlDatabase(action="runStatement") with ALTER TABLEquerySqlDatabase(action="runQuery")mermaidDiagram: Complete mermaid classDiagram codepublish: Whether to publish model immediately (recommend default to false, create then publish)updateMode: Create new model or update existing modelclassDiagram
class User {
username: string <<Username>>
email: email <<Email>>
password: string <<Password>>
avatar: x-image <<Avatar>>
status: x-enum = "active" <<Status>>
required() ["username", "email"]
unique() ["username", "email"]
enum_status() ["active", "inactive", "banned"]
display_field() "username"
}
classDiagram
class Product {
name: string <<Product Name>>
price: number <<Price>>
description: x-rtf <<Product Description>>
images: x-image[] <<Product Images>>
category: string <<Category>>
stock: number = 0 <<Stock>>
required() ["name", "price"]
display_field() "name"
}
class Order {
orderNo: string <<Order Number>>
totalAmount: number <<Total Amount>>
status: x-enum = "pending" <<Order Status>>
createTime: datetime <<Create Time>>
required() ["orderNo", "totalAmount"]
unique() ["orderNo"]
enum_status() ["pending", "paid", "shipped", "completed", "cancelled"]
display_field() "orderNo"
}
classDiagram
class Article {
title: string <<Title>>
content: x-rtf <<Content>>
author: string <<Author>>
publishTime: datetime <<Publish Time>>
status: x-enum = "draft" <<Status>>
tags: string[] <<Tags>>
required() ["title", "content", "author"]
enum_status() ["draft", "published", "archived"]
display_field() "title"
}
These rules will guide AI Agents to generate high-quality, business-requirement-compliant data models during the data modeling process.
Weekly Installs
560
Repository
GitHub Stars
39
First Seen
Jan 22, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex490
opencode490
gemini-cli481
github-copilot468
kimi-cli460
amp457
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
106,200 周安装
| string[] |
| Location | x-location |
Field Descriptions : For each field definition in user descriptions, use <<description>> format at the end of the definition line, e.g., name: string <<Name>>.
Display Field : Each entity class should have a field for display when being referenced. Usually a human-readable name or unique identifier. Define display_field() parameterless function, return value is a field name representing the main display field, e.g., display_field() "name" means the main display field is name. Otherwise, default to the implicit _id of the data model.
Class Notes : After all class definitions are complete, use note to describe class names. First use "%% Class naming" to anchor the area, then provide Chinese table names for each class.
Relationships : When descriptions contain relationships, relationship label LabelText should not use original semantics, but use relationship field names. For example, A "n" <-- "1" B: field1 means A has many-to-one relationship with B, data exists in A's field1 field. Refer to examples for specifics.
Naming : Field names and descriptions in Mermaid should be concise and accurately expressed.
Complexity Control : Unless user requires, control complexity, e.g., number of classes should not exceed 5, control field complexity.