mysql 用户角色权限表建立

来源:互联网 发布:网络电话交换机设置 编辑:程序博客网 时间:2024/06/05 11:01

建表sql

#创建表使用的数据库use springmvc; #权限表 create table authoritys(  id_ smallint unsigned primary key auto_increment,#权限id  name_ varchar(24) not null unique,#权限名字  remark_ varchar(200) #备注);#角色表  create table roles(id_ smallint unsigned primary key auto_increment, #角色id name_ varchar(24) not null unique,#角色名字  remark_ varchar(200)#备注);#角色权限表  create table roleAuthority(  role_id_ smallint unsigned,#角色id  authority_id_ smallint unsigned,#权限id   primary key(role_id_,authority_id_),#主键  foreign key(role_id_ ) references roles(role_id_ ),#外键角色id 引用角色表角色id  foreign key(authority_id_) references authoritys(authority_id_)#外键权限id 引用权限表权限id); #用户表 create table users(  id_ smallint unsigned primary key auto_increment,#用户id  name_ varchar(24) not null unique,#用户名称  password_ char(20) not null,#密码  create_time_ datetime not null,#创建时间  creator_id_ smallint unsigned, #创建者id    remark_ varchar(200),#备注  foreign key(creator_id_) references users(user_id_)#外键 创建者id 引用用户表用户id );#用户角色表  create table userRole(user_id_ smallint unsigned,#用户id  role_id_ smallint unsigned,#角色id  primary key(user_id_,role_id_),#主键 用户id 角色id  foreign key(userID) references users(user_id_),#外键用户id 引用用户表用户id  foreign key(roleID) references roles(role_id_)#外键角色id 引用角色表角色id );#菜单表create table menus(id_ smallint unsigned primary key auto_increment,#菜单idname_ch_ varchar(100),#中文名字name_en_ varchar(200),#英文名字parent_id_ smallint unsigned,#父节点id order_id_ smallint unsigned,#同一父节点下的排序menu_auth_ varchar(200),#菜单对应的权限auth_id_ smallint unsigned,#权限对应idimg_url_ varchar(200)#菜单图片对应的链接);#外键一般去掉 用逻辑控制


0 0
原创粉丝点击