← 返回 Skills 市场
encryptshawn

MySQL8 CRM Schema Design Expert

作者 EncryptShawn · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
88
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install mysql8-crm-schema-expert
功能描述
MySQL 8 database schema design for CRM systems. Use this skill whenever the user needs to design, review, optimize, or generate database schemas for Customer...
使用说明 (SKILL.md)

MySQL 8 CRM Database Design Skill

A comprehensive guide for designing production-quality MySQL 8 database schemas for CRM (Customer Relationship Management) systems. This skill covers everything from core entity design to advanced patterns like EAV custom fields, polymorphic activities, audit trails, and multi-tenant architectures.

How to Use This Skill

This skill is organized into a main guide (this file) and detailed reference documents. Read the relevant reference file before generating any SQL or making design decisions.

Reference Files

Read these from references/ as needed:

File When to Read
core-entities.md Designing the foundational CRM tables (accounts, contacts, leads, opportunities, etc.)
relationships-and-normalization.md Establishing foreign keys, junction tables, and achieving proper normal forms
indexing-and-performance.md Creating indexes, query optimization, partitioning, and performance tuning
custom-fields-and-flexibility.md Implementing EAV patterns, JSON columns, or hybrid approaches for user-defined fields
audit-and-soft-deletes.md Change tracking, audit trails, soft delete patterns, and compliance logging
activities-and-timeline.md Polymorphic activity feeds, notes, tasks, emails, calls, and event tracking
security-and-multitenancy.md Row-level security, role-based access, tenant isolation, and data privacy
migrations-and-seeding.md Schema versioning, migration scripts, and realistic test data generation
reference-schemas.md Complete example schemas you can use as starting points

Core Design Principles

When designing a CRM database on MySQL 8, always follow these principles:

  1. Relational integrity first. Define FOREIGN KEY constraints at the database level. Never rely on application code alone to maintain referential integrity.

  2. Normalize to 3NF, then denormalize deliberately. Start at Third Normal Form. Only denormalize when you have measured performance evidence, and document the reason.

  3. Consistent naming conventions. Use snake_case for all identifiers. Table names are plural (contacts, accounts). Foreign keys follow the pattern {singular_referenced_table}_id (e.g., account_id). Timestamps are created_at, updated_at, deleted_at.

  4. Every table gets an audit baseline. At minimum: id (BIGINT UNSIGNED AUTO_INCREMENT), created_at, updated_at. Most CRM tables also need created_by and updated_by.

  5. Soft deletes over hard deletes. CRM data has legal, compliance, and historical reporting value. Use deleted_at (TIMESTAMP NULL) rather than DELETE statements.

  6. Use BIGINT UNSIGNED for primary keys. INT runs out at ~2.1 billion. CRM tables like activities and audit logs grow fast. BIGINT UNSIGNED gives you headroom through 18.4 quintillion.

  7. UTF8MB4 everywhere. Always CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci. Customer names, notes, and communications contain international characters and emoji.

  8. InnoDB only. All tables use InnoDB for transaction support, row-level locking, foreign key enforcement, and crash recovery.

  9. Timestamps use DATETIME(3) or TIMESTAMP. For CRM, prefer DATETIME(3) for event times (timezone-independent, millisecond precision). Use TIMESTAMP for created_at/updated_at with DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP.

  10. Design for integration. CRM systems connect to email, marketing, billing, and support tools. Include external_id or external_source columns on entities that sync with third-party systems.

Standard Table Template

Every CRM table should follow this baseline structure:

CREATE TABLE `table_name` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,

    -- entity-specific columns here --

    `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    `deleted_at` TIMESTAMP NULL DEFAULT NULL,
    `created_by` BIGINT UNSIGNED NULL DEFAULT NULL,
    `updated_by` BIGINT UNSIGNED NULL DEFAULT NULL,

    PRIMARY KEY (`id`),
    INDEX `idx_table_name_deleted_at` (`deleted_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

Workflow for Designing a CRM Schema

Follow this sequence when the user asks you to design a CRM database:

  1. Clarify scope. Determine which CRM modules are needed: contacts/accounts, sales pipeline, marketing/campaigns, support/tickets, or all of the above.

  2. Read the relevant reference files. Always start with core-entities.md. Add others based on the modules identified.

  3. Design entities first, relationships second. List the tables and their columns, then define the foreign keys and junction tables.

  4. Apply indexing strategy. Read indexing-and-performance.md and add indexes for every foreign key, every column used in WHERE/JOIN/ORDER BY, and composite indexes for common query patterns.

  5. Add flexibility layer. If the user needs custom fields, read custom-fields-and-flexibility.md and choose between EAV, JSON columns, or a hybrid approach.

  6. Add audit and compliance. Read audit-and-soft-deletes.md and implement the appropriate level of change tracking.

  7. Generate migration scripts. Read migrations-and-seeding.md and output versioned, idempotent migration SQL.

  8. Review and validate. Walk through the schema checking for: missing indexes on FKs, missing NOT NULL constraints, missing default values, orphan risk, and query patterns that would cause full table scans.

MySQL 8 Features to Leverage

These MySQL 8 specific features are particularly valuable for CRM schemas:

  • JSON columns for semi-structured data (custom fields, metadata, integration payloads). See custom-fields-and-flexibility.md.
  • Generated columns (VIRTUAL or STORED) to extract and index JSON values.
  • Functional indexes (8.0.13+) to index expressions without explicit generated columns.
  • Multi-valued indexes (8.0.17+) to index JSON arrays efficiently.
  • Common Table Expressions (CTEs) for recursive queries on hierarchical data (org charts, account hierarchies, nested categories).
  • Window functions for pipeline analytics (running totals, rank, lead/lag).
  • CHECK constraints for data validation at the database level.
  • DEFAULT expressions for computed defaults.
  • Invisible indexes for safe testing of index removal.
  • Descending indexes for optimizing ORDER BY ... DESC queries.

Quick Decision Guide

Situation Action
User needs a full CRM from scratch Read core-entities.md + reference-schemas.md, design all modules
User needs just contacts + accounts Read core-entities.md, design the contact/account module only
User asks about custom fields Read custom-fields-and-flexibility.md
User has performance concerns Read indexing-and-performance.md
User needs GDPR/compliance support Read audit-and-soft-deletes.md + security-and-multitenancy.md
User is building multi-tenant SaaS CRM Read security-and-multitenancy.md
User wants to track all user activity Read activities-and-timeline.md
User needs migration scripts Read migrations-and-seeding.md
User wants a ready-to-use schema Read reference-schemas.md
安全使用建议
This skill appears to do what it claims: provide MySQL 8 CRM schema guidance and example SQL. Before using generated SQL in production, review it carefully and run migrations in a staging environment. Verify tenant filters (tenant_id) and unique/index choices match your app to avoid cross-tenant leaks. Pay attention to sensitive fields: follow the guidance to encrypt highly sensitive columns and never store plaintext secrets. Finally, validate performance/indexing decisions against your real workload and adapt BIGINT/partitioning choices to your scale.
功能分析
Type: OpenClaw Skill Name: mysql8-crm-schema-expert Version: 1.0.0 The 'mysql8-crm-schema-expert' skill bundle is a comprehensive and legitimate resource for designing CRM database schemas. It contains high-quality SQL templates, architectural best practices, and guidance on topics such as multi-tenancy, RBAC, and performance optimization across files like core-entities.md and security-and-multitenancy.md. There is no evidence of malicious code, data exfiltration, or harmful prompt injection; all instructions in SKILL.md are strictly aligned with the stated purpose of assisting users with database design.
能力标签
crypto
能力评估
Purpose & Capability
The name/description match the provided content: detailed MySQL 8 CRM design guidance, reference docs, and example schemas. There are no extraneous environment variables, binaries, or installation steps requested that would be unrelated to database schema design.
Instruction Scope
SKILL.md and the reference files instruct the agent to read local reference files and produce SQL/design recommendations. There are no instructions to read unrelated system files, access credentials, contact external endpoints, or exfiltrate data. The guidance explicitly focuses on schema design, indexing, tenancy, and migration patterns.
Install Mechanism
No install spec or code files that would download or execute external artifacts are present — this is an instruction-only skill, which minimizes disk/execute risk.
Credentials
The skill declares no required environment variables, credentials, or config paths. The content references standard DB practices (encryption, keyrings) but does not request keys or other secrets from the environment.
Persistence & Privilege
always is false and the skill is user-invocable; it does not request persistent privileges or modify other skills or system-wide agent settings. Autonomous invocation is allowed by platform default but is not combined with other concerning capabilities here.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install mysql8-crm-schema-expert
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /mysql8-crm-schema-expert 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release of mysql8-design-crm, a comprehensive skill for CRM database schema design in MySQL 8. - Provides detailed principles and a standard table template for production-quality CRM designs. - Includes step-by-step workflow for designing CRM schemas, emphasizing normalization, auditability, and flexibility. - References topic-based guides for core entities, relationships, indexing, soft deletes, custom fields, audit, activities, security, migrations, and sample schemas. - Highlights essential MySQL 8 features (JSON, generated columns, CTEs, etc.) useful for CRM systems. - Offers a decision matrix for quickly identifying the appropriate design approach based on user needs.
元数据
Slug mysql8-crm-schema-expert
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

MySQL8 CRM Schema Design Expert 是什么?

MySQL 8 database schema design for CRM systems. Use this skill whenever the user needs to design, review, optimize, or generate database schemas for Customer... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 88 次。

如何安装 MySQL8 CRM Schema Design Expert?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install mysql8-crm-schema-expert」即可一键安装,无需额外配置。

MySQL8 CRM Schema Design Expert 是免费的吗?

是的,MySQL8 CRM Schema Design Expert 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

MySQL8 CRM Schema Design Expert 支持哪些平台?

MySQL8 CRM Schema Design Expert 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 MySQL8 CRM Schema Design Expert?

由 EncryptShawn(@encryptshawn)开发并维护,当前版本 v1.0.0。

💬 留言讨论