/*==============================================================*/
/* DBMS name: MySQL 5.0 */
/* Created on: 2019/6/17 15:27:54 */
/*==============================================================*/
drop table if exists tb_permission;
drop table if exists tb_role;
drop table if exists tb_role_permission;
drop table if exists tb_user;
/*==============================================================*/
/* Table: tb_permission */
/*==============================================================*/
create table tb_permission
(
permission_id int not null auto_increment comment '权限id',
permission_name varchar(50) comment '权限名称',
permission_url varchar(150) comment '权限url地址',
perimssion_expression varchar(100) comment '权限表达式',
permission_type int comment '是否是菜单权限
0 普通权限 1 菜单权限',
permission_parent_id int comment '权限父id',
permission_sorting int comment '权限菜单时候排序升序',
primary key (permission_id)
);
/*==============================================================*/
/* Table: tb_role */
/*==============================================================*/
create table tb_role
(
role_id int not null auto_increment comment '角色id',
role_name varhcar(50) comment '角色名称',
user_desc varchar(500) comment '角色描述',
primary key (role_id)
);
/*==============================================================*/
/* Table: tb_role_permission */
/*==============================================================*/
create table tb_role_permission
(
role_id int comment '角色id',
permission_id int comment '权限id',
role_permission_id int not null auto_increment comment '主键',
primary key (role_permission_id)
);
/*==============================================================*/
/* Table: tb_user */
/*==============================================================*/
create table tb_user
(
user_id int not null auto_increment comment '用户id',
user_name varchar(50) comment '名称',
user_account varchar(50) comment '账号',
user_pwd varchar(50) comment '密码',
user_salt varchar(50) comment '盐(密码加密)',
user_desc varchar(500) comment '描述',
user_status int comment '状态 1 可用,0锁定 ,2 ,删除',
role_id int comment '角色id',
primary key (user_id)
);
alter table tb_role_permission add constraint FK_Reference_2 foreign key (role_id)
references tb_role (role_id) on delete restrict on update restrict;
alter table tb_role_permission add constraint FK_Reference_3 foreign key (permission_id)
references tb_permission (permission_id) on delete restrict on update restrict;
alter table tb_user add constraint FK_Reference_1 foreign key (role_id)
references tb_role (role_id) on delete restrict on update restrict;
|