当前位置:网站首页>MySQL表操作练习
MySQL表操作练习
2022-08-05 05:40:00 【小孙的代码分享】
设计一个考勤系统
考勤系统,包含员工表,考勤记录表
主要考虑记录表中的记录信息,是如何关联到员工表,员工与记录关系为1:m。
create TABLE emp(id int primary key,name varchar(20));
create TABLE info(id int primary key,emp_id int,info_date timestamp,foreign key (emp_id) references emp(id));设计一个学校宿舍管理系统
学校宿舍管理系统,要求包含宿舍信息,学生信息,每日的宿舍查房记录。
主要考虑学生与宿舍的关系:m:1,宿舍的查房记录是根据宿舍来查的,与宿舍有关系,一个宿舍可以多次查房,宿舍与查房记录是1:m的关系
create table dormitory(id int primary key,number varchar(20));
create table student(id int primary,name varchar(20),dormitory_id int,FOREIGN KEY(dormitory_id) REFERENCES dormitory(id));
create table info (id int primary key,dormitory_id int,status bit,info_date TIMESTAMP,FOREIGN KEY(dormitory_id) REFERENCES dormitory(id));
设计一个车辆违章系统
车辆违章系统,包含用户表,车辆表,违章信息表。违章信息表中包含用户和车辆的违章信息
用户可以拥有多辆车,关系为1:m,题目已经说明违章信息包括用户和车辆,说明违章信息表中要记录用户和车辆,一个用户可以有多次违章记录,用户与违章记录关系为1:m,一辆车也可以有多次违章记录,车辆与违章记录关系也为1:m
create table user(id int primary key,name varchar(20));
create table cars(id int primary key,name varchar(20),user_id int,foreign key (user_id) references user(id));
create table info(id int primary key,user_id int,cars_id int,foreign key (user_id) references user(id),foreign key (cars_id) references cars(id));设计一个学校食堂管理系统
学校食堂管理系统,包含食堂表,食堂仓口表,仓口收费记录表
一个食堂有多个仓口卖饭,关系为1:m,每个仓口卖饭可以有很多次,仓口与收费记录也是1:m
create table hall(id int primary key, name varchar(20));
create table hall_opening(id int primary key,name varchar(20),hall_id int,foreign key (hall_id) references hall(id));
create table info(id int primary key,price int,info_date timestamp,hall_opening_id int,foreign key (hall_opening_id) references hall_opening(id));
边栏推荐
- 错误记录集锦(遇到则记下)
- Pytorch distributed parallel processing
- ES2020新特性
- Q 2020, the latest senior interview Laya soul, do you know?
- BIO, NIO, AIO practical study notes (easy to understand theory)
- 无法导入torchvision.io.read_image
- export使用
- 人人AI(吴恩达系列)
- Configuration of routers and static routes
- Tencent Internal Technology: Evolution of Server Architecture of "The Legend of Xuanyuan"
猜你喜欢
随机推荐
农场游戏果园系统+牧场养殖系统+广告联盟模式流量主游戏小程序APP V1
NACOS配置中心设置配置文件
Jenkins详细配置
Redis的使用
Transformer详细解读与预测实例记录
docker部署完mysql无法连接
The size of the screen adaptation
Come, come, let you understand how Cocos Creator reads and writes JSON files
亚马逊美国站:马术头盔CPC认证标准要求
Detailed explanation of the construction process of Nacos cluster
txt文件英语单词词频统计
Collision, character controller, Cloth components (cloth), joints in the Unity physics engine
Alibaba Cloud Video on Demand
无法导入torchvision.io.read_image
DevOps-了解学习
H5开发调试-Fiddler手机抓包
D45_Camera assembly Camera
MyCat配置文件
ALC experiment
网络排错基础-学习笔记









