【高校宿舍管理系统】第一章 建立数据库以及项目框架搭建

第一章 建立数据库以及项目框架搭建

提示:本博客个为人独立博客,不是权威,仅供参考!所有思路只做交流之用!如有不足之处,望各位在评论区友善指正。



前言

这一章将介绍数据库的建立以及项目框架的搭建
工具:Navicat、IDEA


一、建立数据库

1.新建数据库【dormitory】

在这里插入图片描述

2.建表,执行sql语句一键生成

sql语句:

/*==============================================================*/
/* DBMS name:      MySQL 5.0                                    */
/* Created on:     2021-5-1 10:30:52                            */
/*==============================================================*/


drop table if exists tb_absence;

drop table if exists tb_bed;

drop table if exists tb_building;

drop table if exists tb_dormitory;

drop table if exists tb_dormitory_set;

drop table if exists tb_dormitory_student;

drop table if exists tb_grade;

drop table if exists tb_menu;

drop table if exists tb_notice;

drop table if exists tb_notice_receive;

drop table if exists tb_org;

drop table if exists tb_record;

drop table if exists tb_repair;

drop table if exists tb_selection;

drop table if exists tb_selection_dormitory;

drop table if exists tb_selection_joiner;

drop table if exists tb_storey;

drop table if exists tb_student;

drop table if exists tb_user;

drop table if exists tb_user_menu;

drop table if exists tb_visit;

/*==============================================================*/
/* Table: tb_absence                                            */
/*==============================================================*/
create table tb_absence
(
   id                   int not null auto_increment,
   student_id           int,
   dormitory_id         int,
   start_time           date,
   end_time             date,
   remark               varchar(200),
   primary key (id)
);

/*==============================================================*/
/* Table: tb_bed                                                */
/*==============================================================*/
create table tb_bed
(
   id                   int not null auto_increment,
   bno                  varchar(50),
   dormitory_id         int,
   primary key (id)
);

/*==============================================================*/
/* Table: tb_building                                           */
/*==============================================================*/
create table tb_building
(
   id                   int not null auto_increment,
   name                 varchar(100),
   type                 int comment '4/6/8人间',
   storey_num           int,
   sex                  int,
   remark               varchar(200),
   user_id              int,
   primary key (id)
);

alter table tb_building comment '楼宇';

/*==============================================================*/
/* Table: tb_dormitory                                          */
/*==============================================================*/
create table tb_dormitory
(
   id                   int not null auto_increment,
   no                   varchar(50),
   sex                  int,
   type                 int,
   capacity             int,
   storey_id            int,
   building_id          int,
   primary key (id)
);

/*==============================================================*/
/* Table: tb_dormitory_set                                      */
/*==============================================================*/
create table tb_dormitory_set
(
   id                   int not null auto_increment,
   prefix               varchar(50),
   start                int,
   end                  int,
   building_id          int,
   storey_id            int,
   capacity             int,
   primary key (id)
);

/*==============================================================*/
/* Table: tb_dormitory_student                                  */
/*==============================================================*/
create table tb_dormitory_student
(
   id                   int not null auto_increment,
   dormitory_id         int,
   bed_id               int,
   student_id           int,
   checkin              datetime,
   status               int comment '0待入住/1已入住',
   primary key (id)
);

/*==============================================================*/
/* Table: tb_grade                                              */
/*==============================================================*/
create table tb_grade
(
   id                   int not null auto_increment,
   name                 varchar(100),
   primary key (id)
);

/*==============================================================*/
/* Table: tb_menu                                               */
/*==============================================================*/
create table tb_menu
(
   id                   int not null auto_increment,
   title                varchar(50),
   icon                 varchar(50),
   href                 varchar(100),
   target               varchar(50),
   parent_id            int,
   type                 int comment '0:管理员/宿管员功能:1:学生',
   primary key (id)
);

/*==============================================================*/
/* Table: tb_notice                                             */
/*==============================================================*/
create table tb_notice
(
   id                   int not null auto_increment,
   title                varchar(200),
   content              text,
   create_time          datetime,
   user_id              int,
   filepath             varchar(200),
   primary key (id)
);

/*==============================================================*/
/* Table: tb_notice_receive                                     */
/*==============================================================*/
create table tb_notice_receive
(
   id                   int not null auto_increment,
   notice_id            int,
   building_id          int,
   primary key (id)
);

/*==============================================================*/
/* Table: tb_org                                                */
/*==============================================================*/
create table tb_org
(
   id                   int not null auto_increment,
   name                 varchar(100),
   type                 int comment '1学院/2系/3专业/4班级',
   grade_id             int,
   parent_id            int,
   remark               varchar(200),
   primary key (id)
);

/*==============================================================*/
/* Table: tb_record                                             */
/*==============================================================*/
create table tb_record
(
   id                   int not null auto_increment,
   student_id           int,
   dormitory_id         int,
   bed_id               int,
   status               int comment '1入住/2退宿',
   create_date          datetime,
   primary key (id)
);

/*==============================================================*/
/* Table: tb_repair                                             */
/*==============================================================*/
create table tb_repair
(
   id                   int not null auto_increment,
   student_id           int,
   dormitory_id         int,
   building_id          int,
   description          varchar(500),
   create_date          datetime,
   status               int comment '0待解决/1已解决',
   primary key (id)
);

/*==============================================================*/
/* Table: tb_selection                                          */
/*==============================================================*/
create table tb_selection
(
   id                   int not null auto_increment,
   name                 varchar(100),
   start_time           date,
   end_time             date,
   remark               varchar(100),
   primary key (id)
);

/*==============================================================*/
/* Table: tb_selection_dormitory                                */
/*==============================================================*/
create table tb_selection_dormitory
(
   id                   int not null auto_increment,
   dormitory_id         int,
   clazz_id             int,
   primary key (id)
);

/*==============================================================*/
/* Table: tb_selection_joiner                                   */
/*==============================================================*/
create table tb_selection_joiner
(
   id                   int not null auto_increment,
   selection_id         int,
   clazz_id             int,
   primary key (id)
);

/*==============================================================*/
/* Table: tb_storey                                             */
/*==============================================================*/
create table tb_storey
(
   id                   int not null auto_increment,
   name                 varchar(100),
   building_id          int,
   remark               varchar(200),
   primary key (id)
);

/*==============================================================*/
/* Table: tb_student                                            */
/*==============================================================*/
create table tb_student
(
   id                   int not null auto_increment,
   stu_no               varchar(50),
   name                 varchar(50),
   idcard               varchar(50),
   grade_id             int,
   sex                  int,
   phone                varchar(50),
   password             varchar(50),
   clazz_id             int,
   primary key (id)
);

/*==============================================================*/
/* Table: tb_user                                               */
/*==============================================================*/
create table tb_user
(
   id                   int not null auto_increment,
   user_name            varchar(100),
   password             varchar(100),
   name                 varchar(100),
   phone                varchar(100),
   type                 int comment '0管理员/1宿管员',
   remark               varchar(200),
   primary key (id)
);

/*==============================================================*/
/* Table: tb_user_menu                                          */
/*==============================================================*/
create table tb_user_menu
(
   user_id              int not null,
   menu_id              int not null,
   primary key (user_id, menu_id)
);

/*==============================================================*/
/* Table: tb_visit                                              */
/*==============================================================*/
create table tb_visit
(
   id                   int not null auto_increment,
   visitor              varchar(100),
   phone                varchar(100),
   sex                  int,
   idcard               varchar(100),
   student_id           int,
   visit_time           datetime,
   leave_time           datetime,
   remark               varchar(200),
   primary key (id)
);



新建查询:
在这里插入图片描述
在这里插入图片描述

二、项目框架搭建

1.新建Project

在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述

2.配置Maven

打开-File-Settings
在这里插入图片描述

3.删除不必要的文件

在这里插入图片描述

  • .gitignore:用git做版本控制时,用这个文件控制那些文件或文件夹不被提交
  • HELP.md:你项目的帮助文档,不写可删除
  • mvnw:linux上处理maven版本兼容问题的脚本
  • mvnw.cmd:windows上处理maven版本兼容问题的脚本
  • xxx.iml:是IDEA特有的文件每个导入IDEA的项目都会生成一个项目同名的.iml文件,用于保存你对这个项目的配置。删了程序重新导入后还会生成,但由于配置丢失可能会造成程序异常
  • .mvn:maven配置目录

文件作用解释:
在这里插入图片描述

4.将.properties文件改为.yml文件

在这里插入图片描述在这里插入图片描述

5.创建包

在这里插入图片描述

6.查看mysql-connector-java版本与MySql版本是否对应

POM 是 Project Object Model 的缩写,即项目对象模型。
pom.xml 就是 maven 的配置文件,用以描述项目的各种信息。

查看MySql版本:
在这里插入图片描述使用对应的mysql-connector-java版本
在这里插入图片描述在这里插入图片描述转载自官方文档:https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-versions.html

7.加入驱动信息

在这里插入图片描述用浏览器打开http://localhost:8888/dormitory/
在这里插入图片描述显示如上页面则表示程序运行正常

8.测试

resources文件夹下新建public文件夹

  • public:静态html文件
  • static:静态css、js等
    在这里插入图片描述在这里插入图片描述

总结

数据库的建立是直接提供了sql语句一键生成,没有任何难度。项目的整体框架搭建也给了非常详细的步骤,应该不会有什么大问题。

难点:
1.Maven仓库的配置(不使用IDEA捆绑的Maven)
2.学会查看帮助文档(比如MySql)

第二章预计五一假期结束前更新,涉及SpringBoot整合Mybatis和使用代码生成器生成Mapper相关。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

313YPHU3

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值