mysql-db-model-design

Generate MySQL CREATE TABLE statements with mandatory audit fields and defaults.

Updated Sep 5, 2021
One-click install
npx skills add https://github.com/a747895159/spring-cloud-study-alibaba --skill mysql-db-model-design
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mysql-db-model-design
Source: https://github.com/a747895159/spring-cloud-study-alibaba/tree/main/.agent/skills/mysql-db-model-design
Command: npx skills add https://github.com/a747895159/spring-cloud-study-alibaba --skill mysql-db-model-design

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

在设计、创建或修改 MySQL 数据库表时,强制遵循 Buffalo 项目的统一规范,确保审计字段、默认值与命名约定的一致性。

Core Features & Use Cases

  • 统一审计字段注入:为每张表自动添加 version、is_deleted、created_time、created_by、modified_time、modified_by 等字段并确保 NOT NULL 与默认值。
  • 默认值与 NOT NULL 强制:除主键外的所有字段都必须有默认值,数字型默认为 0,字符串默认为 '',并提供字段注释。
  • DDL 模板与合规输出:提供符合规范的 CREATE TABLE 模板和字段注释,便于快速落地。
  • 参考文档与映射:依赖 references/mysql_db_standard.md,确保与项目标准一致。

Quick Start

Generate a standardized CREATE TABLE statement for a new table following the 6 audit fields and default value rules.

Frequently Asked Questions about mysql-db-model-design

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I standardize MySQL data models and table schemas with mandatory audit fields?

Standardize MySQL data models by injecting mandatory audit fields like version, is_deleted, created_time, and modified_time into every table schema with enforced NOT NULL constraints and consistent default values.

What default values should I use for MySQL schema fields to enforce NOT NULL compliance?

To enforce NOT NULL compliance in MySQL schemas, assign default values to all non-primary key fields: use 0 for numeric types and an empty string '' for string types, ensuring data integrity and avoiding null insertion errors.

How do I generate a standardized CREATE TABLE DDL template for a new MySQL database?

Generate a standardized CREATE TABLE DDL template by including six mandatory audit fields, defining default values for all non-primary key columns, using datetime(3) for time fields, and adding consistent column comments.

Does this MySQL schema design approach require specific time field formats?

Yes, this MySQL schema design approach requires using datetime(3) for all time fields to ensure millisecond precision and standardize temporal data tracking across modified_time and created_time audit columns.

What are the limitations of enforcing default values and audit fields in every MySQL table?

Enforcing default values and audit fields in every MySQL table limits schema flexibility by requiring all non-primary key columns to have defaults and mandating six specific tracking columns, which may increase storage overhead.

Can I use this data model design approach for modifying existing MySQL database schemas?

Yes, you can use this data model design approach when modifying existing MySQL database schemas to retrofit standardized audit fields, enforce default values, and align table structures with project compliance standards.