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

相关推荐
回家路上绕了弯1 小时前
MySQL 详细使用指南:从入门到精通
java·mysql
MaxHua1 小时前
SQL语法大全指南:从基础到进阶的关键字与用法解析
后端·mysql
回家路上绕了弯1 小时前
MySQL 索引详解:从原理到最佳实践
后端·mysql
手把手入门1 小时前
★CentOS:MySQL数据备份
数据库·mysql·adb
用户207038619491 小时前
Compose 可点击文本:ClickableText Compose 中的 ClickableSpan
android
常利兵1 小时前
Kotlin作用域函数全解:run/with/apply/let/also与this/it的魔法对决
android·开发语言·kotlin
幼稚园的山代王1 小时前
Kotlin-基础语法练习一
android·开发语言·kotlin
闻不多2 小时前
用llamaindex搭建GAR遇到400
android·运维·服务器
SelectDB2 小时前
5000+ 中大型企业首选的 Doris,在稳定性的提升上究竟花了多大的功夫?
大数据·数据库·apache
路多辛2 小时前
Golang database/sql 包深度解析(二):连接池实现原理
数据库·sql·golang