MySQL-18.多表设计-一对多

一.多表设计-概述

二.一对多

sql 复制代码
create table tb_emp (
                        id int unsigned primary key auto_increment comment 'ID',
                        username varchar(20) not null unique comment '用户名',
                        password varchar(32) default '123456' comment '密码',
                        name varchar(10) not null comment '姓名',
                        gender tinyint unsigned not null comment '性别, 说明: 1 男, 2 女',
                        image varchar(300) comment '图像',
                        job tinyint unsigned comment '职位, 说明: 1 班主任,2 讲师, 3 学工主管, 4 教研主管',
                        entrydate date comment '入职时间',
                        create_time datetime not null comment '创建时间',
                        update_time datetime not null comment '修改时间',
                        dept_id int unsigned comment '部门id'
) comment '员工表';

create table tb_dept (
    id int unsigned primary key auto_increment comment 'ID',
    name varchar(10) not null unique comment '部门名称',
    create_time datetime not null comment '创建时间',
    update_time datetime not null comment '修改时间'
) comment '部门表';

相关推荐
高溪流11 小时前
3.数据库表的基本操作
数据库·mysql
alonewolf_9911 小时前
深入剖析MySQL锁机制与MVCC原理:高并发场景下的数据库核心优化
数据库·mysql
一 乐11 小时前
绿色农产品销售|基于springboot + vue绿色农产品销售系统(源码+数据库+文档)
java·前端·数据库·vue.js·spring boot·后端·宠物
黄宝康11 小时前
sqlyog密钥亲测有效
mysql
Codeking__11 小时前
Redis初识——什么是Redis
数据库·redis·mybatis
YIN_尹11 小时前
【MySQL】数据类型(上)
android·mysql·adb
k***19511 小时前
Spring 核心技术解析【纯干货版】- Ⅶ:Spring 切面编程模块 Spring-Instrument 模块精讲
前端·数据库·spring
程序员黄老师11 小时前
主流向量数据库全面解析
数据库·大模型·向量·rag
Full Stack Developme12 小时前
Redis 可以实现哪些业务功能
数据库·redis·缓存
rgeshfgreh12 小时前
Spring事务传播机制深度解析
java·前端·数据库