data-model-creation

安装量: 511
排名: #2094

安装

npx skills add https://github.com/tencentcloudbase/skills --skill data-model-creation
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
<>
format at the end of the definition line, e.g.,
name: string <>
.
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 <>
age
:
number = 18 <>
gender
:
x-
enum =
"Male"
<>
classId
:
string <>
identityId
:
string <>
course
:
Course[] <>
required
(
)
["name"]
unique
(
)
["name"]
enum_gender
(
)
["Male", "Female"]
display_field
(
)
"name"
}
class
Class
{
className
:
string <>
display_field
(
)
"className"
}
class
Course
{
name
:
string <>
students
:
Student[] <>
display_field
(
)
"name"
}
class
Identity
{
number
:
string <>
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
executeWriteSQL
with CREATE TABLE
Schema changes → Use
executeWriteSQL
with ALTER TABLE
Basic CRUD → Use appropriate SQL statements directly
Data queries → Use
executeReadOnlySQL
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 <> email : email <> password : string <> avatar : x- image <> status : x- enum = "active" <> required ( ) ["username", "email"] unique ( ) ["username", "email"] enum_status ( ) ["active", "inactive", "banned"] display_field ( ) "username" } E-commerce System classDiagram class Product { name : string <> price : number <> description : x- rtf <> images : x- image[] <> category : string <> stock : number = 0 <> required ( ) ["name", "price"] display_field ( ) "name" } class Order { orderNo : string <> totalAmount : number <> status : x- enum = "pending" <> createTime : datetime <> required ( ) ["orderNo", "totalAmount"] unique ( ) ["orderNo"] enum_status ( ) ["pending", "paid", "shipped", "completed", "cancelled"] display_field ( ) "orderNo" } Content Management System classDiagram class Article { title : string <> 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.</dd> </dl> </dd> </dl> </dd> </dl> </dd> </dl> </dd> </dl> </dd> </dl> </dd> </dl> </dd> </dl> </dd> </dl> </dd> </dl> </dd> </dl> </dd> </dl> </dd> </dl> </dd> </dl> </dd> </dl> </dd> </dl> </dd> </dl> </dd> </dl> </dd> </dl> </dd> </dl> </dd> </dl> </dd> </dl> </dd> </dl> </dd> </dl> </dd> </dl> </dd> </dl> </dd> </dl> </dd> </dl> </dd> </dl> </article> <a href="/" class="back-link">← <span data-i18n="detail.backToLeaderboard">返回排行榜</span></a> </div> <aside class="sidebar"> <section class="related-skills" id="relatedSkillsSection"> <h2 class="related-title" data-i18n="detail.relatedSkills">相关 Skills</h2> <div class="related-list" id="relatedSkillsList"> <div class="skeleton-card"></div> <div class="skeleton-card"></div> <div class="skeleton-card"></div> </div> </section> </aside> </div> </div> <script src="https://unpkg.com/i18next@23.11.5/i18next.min.js" defer></script> <script src="https://unpkg.com/i18next-browser-languagedetector@7.2.1/i18nextBrowserLanguageDetector.min.js" defer></script> <script defer> // Language resources - same pattern as index page const resources = { 'zh-CN': null, 'en': null, 'ja': null, 'ko': null, 'zh-TW': null, 'es': null, 'fr': null }; // Load language files (only current + fallback for performance) async function loadLanguageResources() { const savedLang = localStorage.getItem('i18nextLng') || 'en'; const langsToLoad = new Set([savedLang, 'en']); // current + fallback await Promise.all([...langsToLoad].map(async (lang) => { try { const response = await fetch(`/locales/${lang}.json`); if (response.ok) { resources[lang] = { translation: await response.json() }; } } catch (error) { console.warn(`Failed to load ${lang} language file:`, error); } })); } // Load a single language on demand (for language switching) async function loadLanguage(lang) { if (resources[lang]) return; try { const response = await fetch(`/locales/${lang}.json`); if (response.ok) { resources[lang] = { translation: await response.json() }; i18next.addResourceBundle(lang, 'translation', resources[lang].translation); } } catch (error) { console.warn(`Failed to load ${lang} language file:`, error); } } // Initialize i18next async function initI18n() { try { await loadLanguageResources(); // Filter out null values from resources const validResources = {}; for (const [lang, data] of Object.entries(resources)) { if (data !== null) { validResources[lang] = data; } } console.log('Loaded languages:', Object.keys(validResources)); console.log('zh-CN resource:', validResources['zh-CN']); console.log('detail.home in resource:', validResources['zh-CN']?.translation?.detail?.home); // 检查是否有保存的语言偏好 const savedLang = localStorage.getItem('i18nextLng'); // 如果没有保存的语言偏好,默认使用英文 const defaultLang = savedLang && ['zh-CN', 'en', 'ja', 'ko', 'zh-TW', 'es', 'fr'].includes(savedLang) ? savedLang : 'en'; await i18next .use(i18nextBrowserLanguageDetector) .init({ lng: defaultLang, // 强制设置初始语言 fallbackLng: 'en', supportedLngs: ['zh-CN', 'en', 'ja', 'ko', 'zh-TW', 'es', 'fr'], resources: validResources, detection: { order: ['localStorage'], // 只使用 localStorage,不检测浏览器语言 caches: ['localStorage'], lookupLocalStorage: 'i18nextLng' }, interpolation: { escapeValue: false } }); console.log('i18next initialized, language:', i18next.language); console.log('Test translation:', i18next.t('detail.home')); // Set initial language in selector const langSwitcher = document.getElementById('langSwitcher'); langSwitcher.value = i18next.language; // Update page language updatePageLanguage(); // Language switch event langSwitcher.addEventListener('change', async (e) => { await loadLanguage(e.target.value); // load on demand i18next.changeLanguage(e.target.value).then(() => { updatePageLanguage(); localStorage.setItem('i18nextLng', e.target.value); }); }); } catch (error) { console.error('i18next init failed:', error); } } // Translation helper function t(key, options = {}) { return i18next.t(key, options); } // Update all translatable elements function updatePageLanguage() { // Update HTML lang attribute document.documentElement.lang = i18next.language; // Update elements with data-i18n attribute document.querySelectorAll('[data-i18n]').forEach(el => { const key = el.getAttribute('data-i18n'); el.textContent = t(key); }); } // Copy command function function copyCommand() { const command = document.getElementById('installCommand').textContent; const btn = document.getElementById('copyBtn'); navigator.clipboard.writeText(command).then(() => { btn.textContent = t('copied'); btn.classList.add('copied'); setTimeout(() => { btn.textContent = t('copy'); btn.classList.remove('copied'); }, 2000); }).catch(() => { // Fallback for non-HTTPS const textArea = document.createElement('textarea'); textArea.value = command; textArea.style.position = 'fixed'; textArea.style.left = '-9999px'; document.body.appendChild(textArea); textArea.select(); document.execCommand('copy'); document.body.removeChild(textArea); btn.textContent = t('copied'); btn.classList.add('copied'); setTimeout(() => { btn.textContent = t('copy'); btn.classList.remove('copied'); }, 2000); }); } // Initialize document.getElementById('copyBtn').addEventListener('click', copyCommand); initI18n(); // 异步加载相关 Skills async function loadRelatedSkills() { const owner = 'tencentcloudbase'; const skillName = 'data-model-creation'; const currentLang = 'ja'; const listContainer = document.getElementById('relatedSkillsList'); const section = document.getElementById('relatedSkillsSection'); try { const response = await fetch(`/api/related-skills/${encodeURIComponent(owner)}/${encodeURIComponent(skillName)}?limit=6`); if (!response.ok) { throw new Error('Failed to load'); } const data = await response.json(); const relatedSkills = data.related_skills || []; if (relatedSkills.length === 0) { // 没有相关推荐时隐藏整个区域 section.style.display = 'none'; return; } // 渲染相关 Skills listContainer.innerHTML = relatedSkills.map(skill => { const desc = skill.description || ''; const truncatedDesc = desc.length > 60 ? desc.substring(0, 60) + '...' : desc; return ` <a href="${currentLang === 'en' ? '' : '/' + currentLang}/skill/${skill.owner}/${skill.repo}/${skill.skill_name}" class="related-card"> <div class="related-name">${escapeHtml(skill.skill_name)}</div> <div class="related-meta"> <span class="related-owner">${escapeHtml(skill.owner)}</span> <span class="related-installs">${skill.installs}</span> </div> <div class="related-desc">${escapeHtml(truncatedDesc)}</div> </a> `; }).join(''); } catch (error) { console.error('Failed to load related skills:', error); // 加载失败时显示提示或隐藏 listContainer.innerHTML = '<div class="related-empty">暂无相关推荐</div>'; } } // HTML 转义 function escapeHtml(text) { const div = document.createElement('div'); div.textContent = text; return div.innerHTML; } // 页面加载完成后异步加载相关 Skills if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', loadRelatedSkills); } else { loadRelatedSkills(); } </script> </body> </html>