Database Learning Skill logo

Database Learning Skill

Community
jiushiwon
database-learning-skill

数据库学习与选型技能。面向零基础学习者,系统学习数据结构、事务、索引、查询优化等核心概念,对比 MySQL 与 PostgreSQL 的差异与适用场景。触发词:"数据库学习"、"学数据库"、"数据库入门"、"MySQL vs PostgreSQL"、"数据库索引"、"数据库事务"、"数据库选型"、"数据库查询优化"。

Overview

Publisherjiushiwon
Repositorywg-skills
Skill namedatabase-learning-skill
Stars
123
Forks
38
Bundled files
5
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 5 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by jiushiwon on GitHub. Read the source before you install it.

Installation

Install the Database Learning Skill AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/jiushiwon/wg-skills/tree/main/vibeCoding/backend/database/database-learning-skill
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/jiushiwon/wg-skills.git /tmp/wg-skills
mkdir -p .claude/skills
cp -r /tmp/wg-skills/vibeCoding/backend/database/database-learning-skill .claude/skills/database-learning-skill
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Database Learning Skill in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Database Learning Skill on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Database Learning Skill is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Database Learning Skill

面向零基础学习者,系统学习数据库核心概念,掌握数据库选型与优化能力。

核心理念

数据库 = 数据的仓库 + 管理的艺术

学数据库不是背命令,而是理解:

  • 数据如何组织(表结构)
  • 数据如何关联(关系)
  • 数据如何高效查找(索引)
  • 数据如何安全(事务)
  • 什么场景选什么数据库(选型)

学习路径

数据库入门
    ↓
表结构设计(数据结构)
    ↓
数据查询(SQL 基础)
    ↓
索引与查询优化
    ↓
事务与并发控制
    ↓
MySQL vs PostgreSQL 选型

学习模块

1. 数据结构(表设计)

概念说明
表(Table)数据的二维表格,像 Excel
字段(Column)表的列,如 id、name、age
记录(Row)表的行,一条数据
主键(Primary Key)唯一标识一条记录
外键(Foreign Key)表与表的关联
约束数据的规则(唯一、非空、默认值)

实战:设计一个用户表、一个订单表

2. SQL 查询

操作SQL 关键字
查询SELECT
插入INSERT
更新UPDATE
删除DELETE
条件WHERE
排序ORDER BY
分组GROUP BY
聚合COUNT/SUM/AVG/MAX/MIN

3. 索引(核心)

为什么需要索引?

无索引:逐行扫描 → 10万行 = 10万次 IO
有索引:B+Tree 定位 → 10万行 ≈ 3次 IO
索引类型说明适用场景
主键索引自动唯一,非空主键字段
唯一索引字段值唯一username、email
普通索引加速查找常用查询字段
复合索引多字段组合多条件查询
全文索引文本搜索文章内容搜索

最左前缀原则:复合索引 (a, b, c) 能命中 a、a+b、a+b+c,不能命中 b、c

4. 事务(核心)

什么是事务?

事务 = 一组 SQL 操作,要么全部成功,要么全部失败

转账场景:
1. A 账户 -1000
2. B 账户 +1000
必须一起成功或一起失败

ACID 特性

特性说明
Atomic(原子性)不可分割,要么全成功要么全失败
Consistency(一致性)事务前后数据状态一致
Isolation(隔离性)并发事务互不干扰
Durability(持久性)提交后数据永久保存

隔离级别

级别脏读不可重复读幻读
读未提交有有有
读已提交无有有
可重复读无无有
串行化无无无

MySQL 默认:可重复读(RR) PostgreSQL 默认:读已提交(RC)

5. 查询优化

为什么要优化?

慢查询是数据库性能的最大杀手。一个没有索引的查询可能让整个系统变慢。

如何发现慢查询?

sql
-- MySQL:开启慢查询日志
SHOW VARIABLES LIKE 'slow_query_log';
SELECT * FROM slow_log ORDER BY start_time DESC LIMIT 10;

-- PostgreSQL:查看慢查询统计
SELECT * FROM pg_stat_statements ORDER BY total_time DESC LIMIT 10;

-- 使用 EXPLAIN 分析查询
EXPLAIN SELECT * FROM users WHERE username = 'test';

核心优化思路

  1. 加索引 → WHERE 条件字段必须有索引
  2. **避免 SELECT *** → 只查询需要的字段
  3. 避免函数运算 → WHERE YEAR(created_at)=2024 改为 WHERE created_at >= '2024-01-01'
  4. 分页优化 → 大偏移量用游标分页(WHERE id > last_id)

详细的性能优化规范见 database-design-skill。

6. MySQL vs PostgreSQL 选型

特性MySQLPostgreSQL
定位Web 应用企业级/复杂查询
事务支持支持(更完善)
JSON支持更强(JSONB)
全文搜索基础强大
地理信息插件原生支持
窗口函数支持完整支持
CTEs8.0+ 支持原生支持
主从复制MySQL BinlogPostgreSQL WAL
性能简单查询快复杂查询强
生态广泛增长快

选型建议

场景推荐
博客、CMS、电商MySQL
数据分析、报表PostgreSQL
需要 JSON 文档PostgreSQL
需要 GIS 地理PostgreSQL
团队熟悉 MySQLMySQL
需要事务强一致性PostgreSQL
高并发简单查询MySQL
复杂查询/联表PostgreSQL

设计规范

详细的设计规范(命名、字段类型、索引设计、分库分表等)见 database-design-skill。

速查要点:

  • 命名:英文小写 + 下划线,表前缀 wg_,单数名词
  • 基础字段:id、status、created_at、updated_at、deleted_at
  • 索引:WHERE/ORDER BY/JOIN 字段必须加索引

触发场景

数据库学习:
/database-learning-skill 什么是数据库事务
/database-learning-skill 索引是什么
/database-learning-skill MySQL 和 PostgreSQL 区别
/database-learning-skill 怎么优化慢查询
/database-learning-skill 复合索引怎么用
/database-learning-skill 帮我设计一个用户表

引用索引

文件内容
references/sql-basics.mdSQL 基础语法速查
references/index-guide.md索引详解与实战
references/transaction-guide.md事务与并发控制
references/query-optimization.md查询优化实战
references/mysql-vs-pgsql.mdMySQL vs PG 选型对比

相关技能

  • database-design-skill:数据库设计规范
  • mysql-guide-skill:MySQL 集成
  • pgsql-guide-skill:PostgreSQL 集成
  • springboot-init-skill:后端骨架(含数据库集成)
  • fastapi-init-skill:后端骨架(含数据库集成)
  • go-gin-init-skill:后端骨架(含数据库集成)

不做

  • 不涉及数据库安装部署(参考 database-design-skill)
  • 不涉及数据库集群/高可用架构
  • 不涉及具体 ORM 的使用(各后端 skill 负责)
  • 不涉及 SQL 深度优化(DBA 范畴)

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Database Learning Skill AI skill do?

数据库学习与选型技能。面向零基础学习者,系统学习数据结构、事务、索引、查询优化等核心概念,对比 MySQL 与 PostgreSQL 的差异与适用场景。触发词:"数据库学习"、"学数据库"、"数据库入门"、"MySQL vs PostgreSQL"、"数据库索引"、"数据库事务"、"数据库选型"、"数据库查询优化"。

Why use Database Learning Skill on TypingMind?

Because you install it once and use it with any model. Database Learning Skill is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Database Learning Skill in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/jiushiwon/wg-skills/tree/main/vibeCoding/backend/database/database-learning-skill. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Database Learning Skill?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Database Learning Skill?

As many as you like. As long as a model supports skills, you can use Database Learning Skill with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Database Learning Skill AI skill free?

Yes. It is published on GitHub by jiushiwon under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇