When to use this skill
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:
- Complex multi-table relationships with automatic foreign key management
- Visual ER diagram generation for documentation
- Automated field type mapping and constraint generation
- Enterprise-level data model documentation
For most cases, use relational-database-tool skill instead:
- Simple table creation with CREATE TABLE statements
- Basic CRUD operations
- Schema modifications with ALTER TABLE
- Direct SQL execution without Mermaid modeling
Do NOT use for:
- Querying or manipulating existing data (use database skills)
- NoSQL database design (use NoSQL skills)
- Frontend data structures (use appropriate frontend skills)
How to use this skill (for a coding agent)
⚠️ NOTE: This is OPTIONAL. For simple tasks, skip this and use relational-database-tool directly.
When you do use this advanced modeling approach:
Optional modeling workflow (only when complexity justifies it)
- Business analysis phase: Analyze user requirements, identify core entities and relationships
- Mermaid modeling phase: Create mermaid classDiagram following generation rules
- Model validation phase: Check completeness, consistency, and correctness
Apply generation rules strictly (when using this tool)
- Use correct type mappings (string, number, boolean, x-enum, etc.)
- Convert Chinese to English naming (PascalCase for classes, camelCase for fields)
- Define required(), unique(), display_field() functions when needed
- Use proper relationship notation with field names
Use tools correctly (only when you choose this approach)
- Call data model creation tools only for complex multi-entity business requirements
- Use
mermaidDiagram parameter with complete mermaid classDiagram code
- Set
publish to false initially, create then publish separately
- Choose appropriate
updateMode for new or existing models
Quick Decision Guide
Most Database Tasks → relational-database-tool skill
- ✅ Simple table creation
- ✅ Data queries and modifications
- ✅ Schema changes
- ✅ Direct SQL execution
Complex Modeling Only → This skill (data-model-creation)
- 🎯 Multi-entity relationship modeling
- 🎯 Automated foreign key management
- 🎯 Visual ER diagram generation
- 🎯 Enterprise documentation
Data Model AI Modeling Professional Rules
⚠️ IMPORTANT: Simplified Workflow Recommendation
For most database table creation tasks, use relational-database-tool skill directly:
- Simple table creation:
CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(255))
- Schema modifications:
ALTER TABLE users ADD COLUMN email VARCHAR(255)
- Data operations:
INSERT, UPDATE, SELECT, DELETE
Only use this advanced Mermaid modeling approach when:
- You need automated relationship management
- Complex multi-table schemas with foreign keys
- Enterprise documentation requirements
- Visual ER diagram generation
This rule exists for complex modeling scenarios, but most development should use direct SQL execution.
AI Modeling Expert Prompt
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:
Generation Rules
Type Mapping Priority: When user-described fields match the mapping relationship, prioritize using type as the field type. Mapping relationships are as follows:
| Business Field |
type |
| Text |
string |
| Number |
number |
| Boolean |
boolean |
| Enum |
x-enum |
| Email |
email |
| 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 |
string[] |
| Location |
x-location |
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.
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.
Standard Example
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"
Data Model Creation Workflow
1. Business Analysis Phase
- Carefully analyze user's business requirement descriptions
- Identify core entities and business objects
- Determine relationships between entities
- Clarify required fields, unique constraints, and default values
2. Mermaid Modeling Phase
- Strictly follow the above generation rules to create mermaid classDiagram
- Ensure field type mappings are correct
- Properly handle relationship directions and cardinalities
- Add complete Chinese descriptions and comments
3. Model Validation Phase
- Check model completeness and consistency
- Verify relationship rationality
- Confirm field constraint correctness
- Check naming convention compliance
MySQL Data Type Support
Basic Type Mappings
string → VARCHAR/TEXT
number → INT/BIGINT/DECIMAL
boolean → BOOLEAN/TINYINT
date → DATE
datetime → DATETIME
time → TIME
Extended Type Mappings
x-enum → ENUM type
x-file/x-image → File path storage
x-rtf → LONGTEXT rich text
x-area-code → Region code
x-location → Geographic location coordinates
email/phone/url → VARCHAR with validation
Relationship Implementation
- One-to-one: Foreign key constraints
- One-to-many: Foreign key associations
- Many-to-many: Intermediate table implementation
- Self-association: Same table foreign key
Tool Usage Guidelines
Tool Call Timing (RARE - Use Sparingly)
- Only when user explicitly requests advanced data modeling with Mermaid diagrams
- Only for complex enterprise applications with multi-entity relationships
- Only when user provides detailed business requirement descriptions requiring automated modeling
- Only when you need to update existing data model structure AND want visual ER diagrams
When to SKIP this tool (Most Cases)
- Simple table creation → Use
manageSqlDatabase(action="runStatement") with CREATE TABLE
- Schema changes → Use
manageSqlDatabase(action="runStatement") with ALTER TABLE
- Basic CRUD → Use appropriate SQL statements directly
- Data queries → Use
querySqlDatabase(action="runQuery")
Parameter Usage Guide
mermaidDiagram: Complete mermaid classDiagram code
publish: Whether to publish model immediately (recommend default to false, create then publish)
updateMode: Create new model or update existing model
Error Handling Strategy
- Syntax errors: Check Mermaid syntax format
- Field type errors: Verify type mapping relationships
- Relationship errors: Check relationship directions and cardinalities
- Naming conflicts: Provide renaming suggestions
Best Practices
Model Design Principles
- Single Responsibility: Each entity class is responsible for only one business concept
- Minimize Dependencies: Reduce unnecessary relationships
- Extensibility: Reserve field space for future expansion
- Consistency: Maintain consistency in naming and type usage
Performance Considerations
- Index Design: Create indexes for commonly queried fields
- Field Length: Reasonably set string field lengths
- Relationship Optimization: Avoid excessive many-to-many relationships
- Data Sharding: Consider table sharding strategies for large tables
Security Standards
- Sensitive Fields: Encrypt storage for sensitive information like passwords
- Permission Control: Clarify read/write permissions for fields
- Data Validation: Set appropriate field constraints
- Audit Logs: Add operation records for important entities
Common Business Scenario Templates
User Management System
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"
}
E-commerce System
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"
}
Content Management System
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.
1---
2name: data-model-creation
3description: Optional advanced tool for complex data modeling. For simple table creation, use relational-database-tool directly with SQL statements.
4alwaysApply: false
5metadata:
6 source: https://skillmd.com/skills/infometa/data-model-creation
7---
8
9## When to use this skill
10
11This is an **OPTIONAL advanced modeling tool** for complex database design. Most simple table creation should use `relational-database-tool` directly with SQL statements.
12
13**ONLY use this skill when you specifically need:**
14- Complex multi-table relationships with automatic foreign key management
15- Visual ER diagram generation for documentation
16- Automated field type mapping and constraint generation
17- Enterprise-level data model documentation
18
19**For most cases, use `relational-database-tool` skill instead:**
20- Simple table creation with CREATE TABLE statements
21- Basic CRUD operations
22- Schema modifications with ALTER TABLE
23- Direct SQL execution without Mermaid modeling
24
25**Do NOT use for:**
26- Querying or manipulating existing data (use database skills)
27- NoSQL database design (use NoSQL skills)
28- Frontend data structures (use appropriate frontend skills)
29
30---
31
32## How to use this skill (for a coding agent)
33
34**⚠️ NOTE: This is OPTIONAL. For simple tasks, skip this and use `relational-database-tool` directly.**
35
36When you do use this advanced modeling approach:
37
381. **Optional modeling workflow** (only when complexity justifies it)
39 - Business analysis phase: Analyze user requirements, identify core entities and relationships
40 - Mermaid modeling phase: Create mermaid classDiagram following generation rules
41 - Model validation phase: Check completeness, consistency, and correctness
42
432. **Apply generation rules strictly** (when using this tool)
44 - Use correct type mappings (string, number, boolean, x-enum, etc.)
45 - Convert Chinese to English naming (PascalCase for classes, camelCase for fields)
46 - Define required(), unique(), display_field() functions when needed
47 - Use proper relationship notation with field names
48
493. **Use tools correctly** (only when you choose this approach)
50 - Call data model creation tools only for complex multi-entity business requirements
51 - Use `mermaidDiagram` parameter with complete mermaid classDiagram code
52 - Set `publish` to false initially, create then publish separately
53 - Choose appropriate `updateMode` for new or existing models
54
55---
56
57## Quick Decision Guide
58
59**Most Database Tasks → `relational-database-tool` skill**
60- ✅ Simple table creation
61- ✅ Data queries and modifications
62- ✅ Schema changes
63- ✅ Direct SQL execution
64
65**Complex Modeling Only → This skill (`data-model-creation`)**
66- 🎯 Multi-entity relationship modeling
67- 🎯 Automated foreign key management
68- 🎯 Visual ER diagram generation
69- 🎯 Enterprise documentation
70
71---
72
73# Data Model AI Modeling Professional Rules
74
75## ⚠️ IMPORTANT: Simplified Workflow Recommendation
76
77**For most database table creation tasks, use `relational-database-tool` skill directly:**
78
79- Simple table creation: `CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(255))`
80- Schema modifications: `ALTER TABLE users ADD COLUMN email VARCHAR(255)`
81- Data operations: `INSERT`, `UPDATE`, `SELECT`, `DELETE`
82
83**Only use this advanced Mermaid modeling approach when:**
84- You need automated relationship management
85- Complex multi-table schemas with foreign keys
86- Enterprise documentation requirements
87- Visual ER diagram generation
88
89**This rule exists for complex modeling scenarios, but most development should use direct SQL execution.**
90
91## AI Modeling Expert Prompt
92
93As 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:
94
95### Generation Rules
96
971. **Type Mapping Priority**: When user-described fields match the mapping relationship, prioritize using type as the field type. Mapping relationships are as follows:
98 | Business Field | type |
99 | --- | --- |
100 | Text | string |
101 | Number | number |
102 | Boolean | boolean |
103 | Enum | x-enum |
104 | Email | email |
105 | Phone | phone |
106 | URL | url |
107 | File | x-file |
108 | Image | x-image |
109 | Rich Text | x-rtf |
110 | Region | x-area-code |
111 | Time | time |
112 | Date | date |
113 | DateTime | datetime |
114 | Object | object |
115 | Array | string[] |
116 | Location | x-location |
117
1182. **Naming Convention**: Convert Chinese descriptions to English naming (except enum values). Use PascalCase for class names, camelCase for field names.
119
1203. **Field Visibility**: Use default visibility for fields, do not add "+" or "-".
121
1224. **Array Types**: When descriptions include array types, use specific array formats such as string[], number[], x-rtf[], etc.
123
1245. **Chinese Administrative Regions**: When involving Chinese administrative regions like "province/city/district", use x-area-code field type.
125
1266. **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.
127
1287. **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.
129
1308. **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.
131
1329. **Field Descriptions**: For each field definition in user descriptions, use `<<description>>` format at the end of the definition line, e.g., `name: string <<Name>>`.
133
13410. **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.
135
13611. **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.
137
13812. **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.
139
14013. **Naming**: Field names and descriptions in Mermaid should be concise and accurately expressed.
141
14214. **Complexity Control**: Unless user requires, control complexity, e.g., number of classes should not exceed 5, control field complexity.
143
144### Standard Example
145
146```mermaid
147classDiagram
148 class Student {
149 name: string <<Name>>
150 age: number = 18 <<Age>>
151 gender: x-enum = "Male" <<Gender>>
152 classId: string <<Class ID>>
153 identityId: string <<Identity ID>>
154 course: Course[] <<Courses>>
155 required() ["name"]
156 unique() ["name"]
157 enum_gender() ["Male", "Female"]
158 display_field() "name"
159 }
160 class Class {
161 className: string <<Class Name>>
162 display_field() "className"
163 }
164 class Course {
165 name: string <<Course Name>>
166 students: Student[] <<Students>>
167 display_field() "name"
168 }
169 class Identity {
170 number: string <<ID Number>>
171 display_field() "number"
172 }
173
174 %% Relationships
175 Student "1" --> "1" Identity : studentId
176 Student "n" --> "1" Class : student2class
177 Student "n" --> "m" Course : course
178 Student "n" <-- "m" Course : students
179 %% Class naming
180 note for Student "Student Model"
181 note for Class "Class Model"
182 note for Course "Course Model"
183 note for Identity "Identity Model"
184```
185
186## Data Model Creation Workflow
187
188### 1. Business Analysis Phase
189- Carefully analyze user's business requirement descriptions
190- Identify core entities and business objects
191- Determine relationships between entities
192- Clarify required fields, unique constraints, and default values
193
194### 2. Mermaid Modeling Phase
195- Strictly follow the above generation rules to create mermaid classDiagram
196- Ensure field type mappings are correct
197- Properly handle relationship directions and cardinalities
198- Add complete Chinese descriptions and comments
199
200### 3. Model Validation Phase
201- Check model completeness and consistency
202- Verify relationship rationality
203- Confirm field constraint correctness
204- Check naming convention compliance
205
206## MySQL Data Type Support
207
208### Basic Type Mappings
209- `string` → VARCHAR/TEXT
210- `number` → INT/BIGINT/DECIMAL
211- `boolean` → BOOLEAN/TINYINT
212- `date` → DATE
213- `datetime` → DATETIME
214- `time` → TIME
215
216### Extended Type Mappings
217- `x-enum` → ENUM type
218- `x-file`/`x-image` → File path storage
219- `x-rtf` → LONGTEXT rich text
220- `x-area-code` → Region code
221- `x-location` → Geographic location coordinates
222- `email`/`phone`/`url` → VARCHAR with validation
223
224### Relationship Implementation
225- One-to-one: Foreign key constraints
226- One-to-many: Foreign key associations
227- Many-to-many: Intermediate table implementation
228- Self-association: Same table foreign key
229
230## Tool Usage Guidelines
231
232### Tool Call Timing (RARE - Use Sparingly)
2331. **Only when user explicitly requests advanced data modeling with Mermaid diagrams**
2342. **Only for complex enterprise applications with multi-entity relationships**
2353. **Only when user provides detailed business requirement descriptions requiring automated modeling**
2364. **Only when you need to update existing data model structure AND want visual ER diagrams**
237
238### When to SKIP this tool (Most Cases)
239- Simple table creation → Use `manageSqlDatabase(action="runStatement")` with CREATE TABLE
240- Schema changes → Use `manageSqlDatabase(action="runStatement")` with ALTER TABLE
241- Basic CRUD → Use appropriate SQL statements directly
242- Data queries → Use `querySqlDatabase(action="runQuery")`
243
244### Parameter Usage Guide
245- `mermaidDiagram`: Complete mermaid classDiagram code
246- `publish`: Whether to publish model immediately (recommend default to false, create then publish)
247- `updateMode`: Create new model or update existing model
248
249### Error Handling Strategy
250- Syntax errors: Check Mermaid syntax format
251- Field type errors: Verify type mapping relationships
252- Relationship errors: Check relationship directions and cardinalities
253- Naming conflicts: Provide renaming suggestions
254
255## Best Practices
256
257### Model Design Principles
2581. **Single Responsibility**: Each entity class is responsible for only one business concept
2592. **Minimize Dependencies**: Reduce unnecessary relationships
2603. **Extensibility**: Reserve field space for future expansion
2614. **Consistency**: Maintain consistency in naming and type usage
262
263### Performance Considerations
2641. **Index Design**: Create indexes for commonly queried fields
2652. **Field Length**: Reasonably set string field lengths
2663. **Relationship Optimization**: Avoid excessive many-to-many relationships
2674. **Data Sharding**: Consider table sharding strategies for large tables
268
269### Security Standards
2701. **Sensitive Fields**: Encrypt storage for sensitive information like passwords
2712. **Permission Control**: Clarify read/write permissions for fields
2723. **Data Validation**: Set appropriate field constraints
2734. **Audit Logs**: Add operation records for important entities
274
275## Common Business Scenario Templates
276
277### User Management System
278```mermaid
279classDiagram
280 class User {
281 username: string <<Username>>
282 email: email <<Email>>
283 password: string <<Password>>
284 avatar: x-image <<Avatar>>
285 status: x-enum = "active" <<Status>>
286 required() ["username", "email"]
287 unique() ["username", "email"]
288 enum_status() ["active", "inactive", "banned"]
289 display_field() "username"
290 }
291```
292
293### E-commerce System
294```mermaid
295classDiagram
296 class Product {
297 name: string <<Product Name>>
298 price: number <<Price>>
299 description: x-rtf <<Product Description>>
300 images: x-image[] <<Product Images>>
301 category: string <<Category>>
302 stock: number = 0 <<Stock>>
303 required() ["name", "price"]
304 display_field() "name"
305 }
306 class Order {
307 orderNo: string <<Order Number>>
308 totalAmount: number <<Total Amount>>
309 status: x-enum = "pending" <<Order Status>>
310 createTime: datetime <<Create Time>>
311 required() ["orderNo", "totalAmount"]
312 unique() ["orderNo"]
313 enum_status() ["pending", "paid", "shipped", "completed", "cancelled"]
314 display_field() "orderNo"
315 }
316```
317
318### Content Management System
319```mermaid
320classDiagram
321 class Article {
322 title: string <<Title>>
323 content: x-rtf <<Content>>
324 author: string <<Author>>
325 publishTime: datetime <<Publish Time>>
326 status: x-enum = "draft" <<Status>>
327 tags: string[] <<Tags>>
328 required() ["title", "content", "author"]
329 enum_status() ["draft", "published", "archived"]
330 display_field() "title"
331 }
332```
333
334These rules will guide AI Agents to generate high-quality, business-requirement-compliant data models during the data modeling process.