-- 第五小组宿舍管理系统源代码(表)
CREATE DATABASE dorm_mar_db;
USE dorm_mar_db;
-- 班级表
drop TABLE IF EXISTS class;
CREATE TABLE class (
`class_name` varchar(10) NOT NULL COMMENT '班级名',
`id` int NOT NULL AUTO_INCREMENT COMMENT '班级编号',
PRIMARY KEY (`id`)
);
-- 班主任表
drop TABLE IF EXISTS class_advisor;
CREATE TABLE class_advisor (
`id` int NOT NULL COMMENT '班主任编号',
`advisor_name` varchar(10) NOT NULL COMMENT '班主任姓名',
`gender` enum('F','M') NULL DEFAULT 'M' COMMENT '班主任性别',
`contact` varchar(12) NOT NULL COMMENT '联系方式',
`password` varchar(20) NOT NULL DEFAULT 123456 COMMENT '密码',
`class_id` int NOT NULL COMMENT '班级编号',
PRIMARY KEY (`id`),
CONSTRAINT `class_id_advisor` FOREIGN KEY (`class_id`) REFERENCES `class` (`id`) # 小心外键索引重复
);
-- 楼栋表
drop TABLE IF EXISTS building;
CREATE TABLE building (
`id` int NOT NULL COMMENT '楼栋编号',
`building_name` varchar(10) NULL COMMENT '楼栋名',
`address` json NOT NULL COMMENT '楼栋地址',
PRIMARY KEY (`id`)
);
-- 宿管表
drop TABLE IF EXISTS dorm_supervisor;
CREATE TABLE dorm_supervisor (
`id` int NOT NULL COMMENT '宿管编号',
`supervisor_name` varchar(10) NOT NULL COMMENT '宿管姓名',
`gender` enum('F','M') NULL DEFAULT 'M' COMMENT '宿管性别',
`contact` varchar(12) NOT NULL COMMENT '联系方式',
`password` varchar(20) NOT NULL DEFAULT 123456 COMMENT '密码',
`building_id` int NOT NULL COMMENT '所属楼栋编号',
PRIMARY KEY (`id`),
CONSTRAINT `supervisor_id` FOREIGN KEY (`building_id`) REFERENCES `building` (`id`)
)
;
-- 宿舍表
DROP TABLE IF EXISTS dormitory;
CREATE TABLE dormitory (
`id` int NOT NULL COMMENT '宿舍编号',
`type` enum('男生宿舍','女生宿舍') NOT NULL COMMENT '宿舍类型',
PRIMARY KEY (`id`)
);
-- 学生表
DROP TABLE IF EXISTS student;
CREATE TABLE student (
`id` int COMMENT '学号',
`stu_name` varchar(10) NOT NULL COMMENT '学生姓名',
`gender` enum('F','M') NOT NULL COMMENT '学生性别',
`contact` varchar(12) NOT NULL COMMENT '联系方式',
`password` varchar(20) NOT NULL DEFAULT 123456 COMMENT '学生密码',
`class_id` int NOT NULL COMMENT '班级编号',
`dor_id` int NOT NULL COMMENT '宿舍编号',
PRIMARY KEY (`id`),
CONSTRAINT `class_id_student` FOREIGN KEY (`class_id`) REFERENCES`class` (`id`),
CONSTRAINT `dor_id_student` FOREIGN KEY (`dor_id`) REFERENCES`dormitory` (`id`)
);
-- 宿舍电量表
DROP TABLE IF EXISTS electricity;
CREATE TABLE electricity (
`id` int NOT NULL COMMENT '编号',
`dor_id` int NOT NULL COMMENT '宿舍编号',
`battery` double NOT NULL DEFAULT 150 COMMENT '剩余电量',
`used_elect` double NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
CONSTRAINT `dor_elect` FOREIGN KEY (`dor_id`) REFERENCES `dormitory` (`id`)
);
-- 外来人员表
DROP TABLE IF EXISTS external_visitor;
CREATE TABLE external_visitor (
`id` int NOT NULL COMMENT '外来人员编号',
`visitor_name` varchar(10) NOT NULL COMMENT '外来人员姓名\r\n',
`gender` enum('F','M') NOT NULL DEFAULT 'M' COMMENT '外来人员性别',
`contact` varchar(12) NOT NULL COMMENT '联系方式',
`supervisor_id` int NOT NULL COMMENT '宿管编号',
`visit_start` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '来访时间',
`vist_end` datetime NULL DEFAULT NULL COMMENT '离开时间',
`reason` varchar(50) NOT NULL COMMENT '来访事由',
PRIMARY KEY (`id`),
CONSTRAINT `supervisor_id_visitor` FOREIGN KEY (`supervisor_id`) REFERENCES `dorm_supervisor` (`id`)
);
-- 物品表
DROP TABLE IF EXISTS asset;
CREATE TABLE asset (
`id` int NOT NULL AUTO_INCREMENT COMMENT '物品编号',
`name` varchar(20) NOT NULL COMMENT '物品名称',
`type` enum('电器','家具','其他') NOT NULL DEFAULT '其他' COMMENT '物品类别',
`state` enum('正常','损坏') NOT NULL DEFAULT '正常' COMMENT '物品状态',
`dor_id` int NULL COMMENT '宿舍号',
PRIMARY KEY (`id`),
CONSTRAINT `dor_id_asset` FOREIGN KEY (`dor_id`) REFERENCES `dorm_mar_db`.`dormitory` (`id`)
);
-- 投诉表
DROP TABLE IF EXISTS complaint;
CREATE TABLE complaint (
`id` int NOT NULL COMMENT '编号',
`student_id` int COMMENT '投诉者编号',
`type` enum('学生间纠纷','其他纠纷') NOT NULL DEFAULT '学生间纠纷' COMMENT '投诉类型',
`describe` varchar(50) NULL COMMENT '描述',
`address` json NOT NULL COMMENT '事发地点',
PRIMARY KEY (`id`),
CONSTRAINT `stu_id_comp` FOREIGN KEY (`student_id`) REFERENCES `student` (`id`)
);
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 2 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/de50ac10e30e41b89db28203f97239be_qq_41701956.jpg!1)
Java程序员-张凯
- 粉丝: 1w+
- 资源: 6825
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
- 使用matplotlib库绘制简单图表的例子.rar
- 九阴真经OL资源解包工具
- python-leetcode面试题解之第307题区域和检索.zip
- python-leetcode面试题解之第305题岛屿数量II.zip
- python-leetcode面试题解之第304题二维区域和检索.zip
- python-leetcode面试题解之第303题区域和检索.zip
- python-leetcode面试题解之第299题猜数字游戏.zip
- python-leetcode面试题解之第298题二叉树最长连续序列.zip
- python-leetcode面试题解之第296题最佳的碰头地点.zip
- python-leetcode面试题解之第294题翻转游戏II.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)