You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

228 lines
7.8 KiB

/*==============================================================*/
/* DBMS name: MySQL 5.0 */
/* Created on: 2022/3/16 16:27:16 */
/*==============================================================*/
drop table if exists Attacheds;
drop table if exists Diseases;
drop table if exists Hospitals;
drop table if exists Menus;
drop table if exists News;
drop table if exists Parts;
drop table if exists ReportTemplates;
drop table if exists Reports;
drop table if exists RoleMenu;
drop table if exists Roles;
drop table if exists UserRole;
drop table if exists Users;
/*==============================================================*/
/* Table: Attacheds */
/*==============================================================*/
create table Attacheds
(
AttachedId int not null auto_increment,
UserId int,
NewId int,
FileName varchar(200),
AttachedTime datetime,
FileSize varchar(20),
primary key (AttachedId)
);
/*==============================================================*/
/* Table: Diseases */
/*==============================================================*/
create table Diseases
(
DiseasesId int not null auto_increment,
DiseasesName varchar(100),
DiseasesCode varchar(100),
Description varchar(500),
primary key (DiseasesId)
);
/*==============================================================*/
/* Table: Hospitals */
/*==============================================================*/
create table Hospitals
(
HospitalId int not null auto_increment,
HospitalName varchar(100),
HospitalCode varchar(30),
Address varchar(50),
Phone varchar(30),
primary key (HospitalId)
);
/*==============================================================*/
/* Table: Menus */
/*==============================================================*/
create table Menus
(
MenuId int not null auto_increment,
MenuName varchar(20),
MenuCode varchar(30),
Description varchar(100),
ParentId int,
primary key (MenuId)
);
/*==============================================================*/
/* Table: News */
/*==============================================================*/
create table News
(
NewId int not null auto_increment,
UserId int,
PartId int,
Title varchar(200),
Content text,
Time datetime,
primary key (NewId)
);
/*==============================================================*/
/* Table: Parts */
/*==============================================================*/
create table Parts
(
PartId int not null auto_increment,
PartName varchar(30),
PartCode varchar(30),
Description varchar(200),
primary key (PartId)
);
/*==============================================================*/
/* Table: ReportTemplates */
/*==============================================================*/
create table ReportTemplates
(
ReportTemplateId int not null auto_increment,
DiseasesId int,
Question varchar(300),
IfMust bit,
Type varchar(20) comment 'int <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
decimal С<EFBFBD><EFBFBD>
date ʱ<EFBFBD><EFBFBD>
string <EFBFBD>ı<EFBFBD>',
primary key (ReportTemplateId)
);
/*==============================================================*/
/* Table: Reports */
/*==============================================================*/
create table Reports
(
ReportId int not null auto_increment,
DiseasesId int,
ReportTemplateId int,
UserId int,
ReportContent varchar(500),
ReportTime datetime,
primary key (ReportId)
);
/*==============================================================*/
/* Table: RoleMenu */
/*==============================================================*/
create table RoleMenu
(
RoleMenuId int not null auto_increment,
RoleId int,
MenuId int,
primary key (RoleMenuId)
);
/*==============================================================*/
/* Table: Roles */
/*==============================================================*/
create table Roles
(
RoleId int not null auto_increment,
RoleName varchar(20),
RoleCode varchar(20),
Description varchar(300),
primary key (RoleId)
);
/*==============================================================*/
/* Table: UserRole */
/*==============================================================*/
create table UserRole
(
UserRoleId int not null auto_increment,
RoleId int,
UserId int,
primary key (UserRoleId)
);
/*==============================================================*/
/* Table: Users */
/*==============================================================*/
create table Users
(
UserId int not null auto_increment,
HospitalId int,
UserName varchar(30),
UserCode varchar(30),
Password varchar(16),
Phone varchar(20),
Department varchar(20),
DepartCode varchar(20),
primary key (UserId)
);
alter table Attacheds add constraint FK_Reference_15 foreign key (NewId)
references News (NewId) on delete restrict on update restrict;
alter table Attacheds add constraint FK_Reference_8 foreign key (UserId)
references Users (UserId) on delete restrict on update restrict;
alter table News add constraint FK_Reference_13 foreign key (PartId)
references Parts (PartId) on delete restrict on update restrict;
alter table News add constraint FK_Reference_5 foreign key (UserId)
references Users (UserId) on delete restrict on update restrict;
alter table ReportTemplates add constraint FK_Reference_9 foreign key (DiseasesId)
references Diseases (DiseasesId) on delete restrict on update restrict;
alter table Reports add constraint FK_Reference_10 foreign key (DiseasesId)
references Diseases (DiseasesId) on delete restrict on update restrict;
alter table Reports add constraint FK_Reference_11 foreign key (ReportTemplateId)
references ReportTemplates (ReportTemplateId) on delete restrict on update restrict;
alter table Reports add constraint FK_Reference_12 foreign key (UserId)
references Users (UserId) on delete restrict on update restrict;
alter table RoleMenu add constraint FK_Reference_3 foreign key (RoleId)
references Roles (RoleId) on delete restrict on update restrict;
alter table RoleMenu add constraint FK_Reference_4 foreign key (MenuId)
references Menus (MenuId) on delete restrict on update restrict;
alter table UserRole add constraint FK_Reference_1 foreign key (RoleId)
references Roles (RoleId) on delete restrict on update restrict;
alter table UserRole add constraint FK_Reference_2 foreign key (UserId)
references Users (UserId) on delete restrict on update restrict;
alter table Users add constraint FK_Reference_14 foreign key (HospitalId)
references Hospitals (HospitalId) on delete restrict on update restrict;