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 '部门表';

相关推荐
@大嘴巴子几秒前
MySQL知识回顾总结----数据库基础
数据库·mysql
lubiii_几秒前
SQL手工测试(MySQL数据库)
数据库·mysql·web安全·网络安全
凌辰揽月8 分钟前
Web后端基础(基础知识)
java·开发语言·前端·数据库·学习·算法
想你依然心痛12 分钟前
数据库入门:从原理到应用
数据库
咕噜企业签名分发-淼淼15 分钟前
如何实现安卓端与苹果端互通的多种方案
android
wu_android1 小时前
Android 线性布局中常见的冲突属性总结
android
恋猫de小郭1 小时前
为什么跨平台框架可以适配鸿蒙,它们的技术原理是什么?
android·前端·flutter
20242817李臻2 小时前
20242817李臻-安全文件传输系统-项目验收
数据库·安全
行思理2 小时前
MongoDB慢查询临时开启方法讲解
数据库·mongodb
bbsh20992 小时前
WebFuture 升级提示“不能同时包含聚集KEY和大字段””的处理办法
数据库·sql·mysql·webfuture