来源:http://hi.baidu.com/%CD%F5%BF%C6%BE%FC/blog/item/b9bf7f13b0551e1cb8127b6f.html

*/
use [master]
go
-- 检查数据库 [RBAC]是否存在,如果存在则删除(只测试用,不然会丢数据.)
-- Search from the sysdatabase to see that if the [RBAC] database exist.
-- If exists then drop it else create it.

if exists(select * from sysdatabases where name = 'RBAC')
   drop database [RBAC]
go

-- 创建数据库 [RBAC]
-- Create the database named by '[RBAC]'.
create database [RBAC]
go

-- 使用数据库 [RBAC]
-- Use the database of '[RBAC]'.
use [RBAC]
go

-- 创建 "用户" 数据表 [RBAC_User]
-- Create the datatable named by '[RBAC_User]' to save users.
create table [RBAC_User]
(
--用户编号
[User_ID] int primary key not null,
--用户名称
[User_Name] varchar(20) not null,
--用户密码
[User_PassWord] varchar(20) not null,
--用户状态
[User_Lock] bit not null
)
go

-- 添加测试数据
-- Add data for test
insert into [RBAC_User] values(1,'FightingYang','PassWord',0);
go
insert into [RBAC_User] values(2,'Supper3000','Teacher',0);
go
insert into [RBAC_User] values(3,'JianzhongLi','Teacher',1);
go

select * from [RBAC_User]
go

-- 创建 "组" 数据表 [RBAC_Group]
-- Create the datatable named by '[RBAC_Group]' to save groups.
create table [RBAC_Group]
(
--组编号
[Group_ID] int primary key not null,
--组名称
[Group_Name] varchar(20) not null
)
go

-- 添加测试数据
-- Add data for test
insert into [RBAC_Group] values(1,'编程爱好者');
go
insert into [RBAC_Group] values(2,'MSDN老师');
go

select * from [RBAC_Group]
go

-- 创建 "角色" 数据表 [RBAC_Role]
-- Create the datatable named by '[RBAC_Role]' to save roles.
create table [RBAC_Role]
(
--角色编号
[Role_ID] int primary key not null,
--角色名称
[Role_Name] varchar(20) not null
)
go

-- 添加测试数据
-- Add data for test
insert into [RBAC_Role] values(1,'admin');
go
insert into [RBAC_Role] values(2,'user');
go

select * from [RBAC_Role]
go

-- 创建 "资源" 数据表 [RBAC_Resource]
-- Create the datatable named by '[RBAC_Resource]' to save Resources.
create table [RBAC_Resource]
(
--资源编号
[Resource_ID] int primary key not null,
--资源名称
[Resource_Name] varchar(20) not null
)
go

-- 添加测试数据
-- Add data for test
insert into [RBAC_Resource] values(1,'音频');
go
insert into [RBAC_Resource] values(2,'视频');
go

select * from [RBAC_Resource]
go

-- 创建 "操作" 数据表 [RBAC_Operate]
-- Create the datatable named by '[RBAC_Operate]' to save Operates.
create table [RBAC_Operate]
(
--操作编号
[Operate_ID] int primary key not null,
--操作名称
[Operate_Name] varchar(10) not null
)
go

-- 添加测试数据
-- Add data for test
insert into [RBAC_Operate] values(1,'添加');
go
insert into [RBAC_Operate] values(2,'读取');
go
insert into [RBAC_Operate] values(3,'编写');
go
insert into [RBAC_Operate] values(4,'删除');
go

select * from [RBAC_Operate]
go

-- 创建 "权限" 数据表 [RBAC_Privilege]
-- Create the datatable named by [RBAC_Privilege] to save privileges.
create table [RBAC_Privilege]
(
--权限编号
[Privilege_ID] int primary key not null,
--资源编号
[Resource_ID] int foreign key references [RBAC_Resource]([Resource_ID]) not null,
--操作编号
[Operate_ID] int foreign key references [RBAC_Operate]([Operate_ID]) not null
)
go

-- 添加测试数据
-- Add data for test
select * from [RBAC_Privilege]
go
-- 第一条权限是对"音频"的"添加"权限
insert into [RBAC_Privilege] values(1,1,1);
go
-- 第二条权限是对"音频"的"读取"权限
insert into [RBAC_Privilege] values(2,1,2);
go
-- 第三条权限是对"音频"的"编写"权限
insert into [RBAC_Privilege] values(3,1,3);
go
-- 第四条权限是对"音频"的"删除"权限
insert into [RBAC_Privilege] values(4,1,4);
go
-- 第五条权限是对"视频"的"读取"权限
insert into [RBAC_Privilege] values(5,2,1);
go
-- 第六条权限是对"视频"的"读取"权限
insert into [RBAC_Privilege] values(6,2,2);
go
-- 第七条权限是对"视频"的"编写"权限
insert into [RBAC_Privilege] values(7,2,3);
go
-- 第八条权限是对"视频"的"删除"权限
insert into [RBAC_Privilege] values(8,2,4);
go

select * from [RBAC_Operate]
go

-- 创建 "授权" 数据表 [RBAC_Impower]
-- Create the datatable named by [RBAC_Impower] to save Impower.
create table [RBAC_Impower]
(
--授权编号
[Impower_ID] int primary key not null,
--角色编号
[Role_ID] int foreign key references [RBAC_Role]([Role_ID]) not null,
--权限编号
[Privilege_ID] int foreign key references [RBAC_Privilege]([Privilege_ID]) not null
)
go

-- 添加测试数据
-- Add data for test
-- 第一条授权内容"admin"具有'对"音频"的"添加"权限'
insert into [RBAC_Impower] values(1,1,1);
go
-- 第二条授权内容"admin"具有'对"音频"的"读取"权限'
insert into [RBAC_Impower] values(2,1,2);
go
-- 第三条授权内容"admin"具有'对"音频"的"编写"权限'
insert into [RBAC_Impower] values(3,1,3);
go
-- 第四条授权内容"admin"具有'对"音频"的"删除"权限'
insert into [RBAC_Impower] values(4,1,4);
go
-- 第五条授权内容"admin"具有'对"视频"的"添加"权限'
insert into [RBAC_Impower] values(5,1,5);
go
-- 第六条授权内容"admin"具有'对"视频"的"读取"权限'
insert into [RBAC_Impower] values(6,1,6);
go
-- 第七条授权内容"admin"具有'对"视频"的"编写"权限'
insert into [RBAC_Impower] values(7,1,7);
go
-- 第八条授权内容"admin"具有'对"视频"的"删除"权限'
insert into [RBAC_Impower] values(8,1,8);
go
-- 第九条授权内容"user"具有'对"音频"的"读取"权限'
insert into [RBAC_Impower] values(9,2,1);
go
-- 第十条授权内容"user"具有'对"视频"的"读取"权限'
insert into [RBAC_Impower] values(10,2,5);
go

select * from [RBAC_Impower]
go

--创建“角色权限”数据表
create table [RBAC_GroupRole]
(
--角色权限编号
[GroupRole_ID] int primary key not null,
--资源编号
[Resource_ID] int foreign key references [RBAC_Resource]([Resource_ID]) not null,
--角色编号
[Group_ID] int foreign key references [RBAC_Group]([Group_ID]) not null
)
go
-- 添加测试数据
-- Add data for test

-- 组所具备的角色的数据第一条的内容是"MSDN老师"具有"admin"的角色
insert into [RBAC_GroupRole] values(1,2,1);
go
-- 组所具备的角色的数据第二条的内容是"编程爱好者"具有"user"的角色
insert into [RBAC_GroupRole] values(2,1,2);
go
select * from [RBAC_GroupRole]
go

-- 创建 "用户组" 数据表 [RBAC_UserGroupRole]
-- Create the datatable named by '[RBAC_UserGroupRole]' to save userGroupRoles.
create table [RBAC_UserGroupRole]
(
--用户组编号
[UserGroup_ID] int primary key not null,
--用户编号
[User_ID] int foreign key references [RBAC_User]([User_ID]) not null,
--组编号
[Group_ID] int foreign key references [RBAC_Group]([Group_ID]) not null,
--角色编号
[Role_ID] int foreign key references [RBAC_Role]([Role_ID]) not null
)
go

-- 添加测试数据
-- Add data for test

-- 第一条用户组数据是"FightingYang"属于"编程爱好者"组,在组中的角色是"admin"
insert into [RBAC_UserGroupRole] values(1,1,1,1);
go
-- 第二条用户组数据是"Supper3000"属于"MSDN老师"组,在组中的角色是"admin"
insert into [RBAC_UserGroupRole] values(2,2,2,1);
go
-- 第三条用户组数据是"JianzhongLi"属于"MSDN老师"组,在组中的角色是"user"
insert into [RBAC_UserGroupRole] values(3,3,2,2);
go

select * from [RBAC_UserGroupRole]
go

基于角色的权限管理数据库设计(RBAC)相关推荐

  1. SQL——一种简单的基于角色控制的权限管理数据库设计DEMO

    -- ---------------------------- -- Table structure for resource -- ---------------------------- DROP ...

  2. Spring Security基于角色的权限管理

    1.Spring Security 1.1核心领域概念 认证(Authentication):认证是建立主体(principal)的过程. 主体通常是指在应用程序中执行操作的用户.设备或其他系统 授权 ...

  3. 从零开始——基于角色的权限管理01(补充)

    此博文较为详细的介绍从零开始--基于角色的权限管理01文中的两个部分的流程(解释代码). 1) index.jsp中提交跳转action action的login,获取jsp页面传过来的用户名密码和验 ...

  4. Jenkins 中基于角色的权限管理

    Jenkins 中基于角色的权限管理 原文地址: Jenkins 中基于角色的权限管理 | 超级小豆丁 (mydlq.club) 系统环境: Jenkins 版本:2.213 一.简介 Jenkins ...

  5. DataBseDesign工作笔记001---基于RBAC用户权限管理数据库设计_用图的形式说明_精确到页面的元素

    JAVA技术交流QQ群:170933152 RBAC(Role-Based Access Control,基于角色的访问控制),就是用户通过角色与权限进行关联.简单地说,一个用户拥有若干角色,每一个角 ...

  6. Mysql--用户权限管理数据库设计(RBAC)

    RBAC(Role-Based Access Control,基于角色的访问控制),就是用户通过角色与权限进行关联.简单地说,一个用户拥有若干角色,每一个角色拥有若干权限.这样,就构造成"用 ...

  7. 会员权限 表设计mysql_用户权限管理数据库设计

    RBAC(Role-Based Access Control,基于角色的访问控制),就是用户通过角色与权限进行关联.简单地说,一个用户拥有若干角色,每一个角色拥有若干权限.这样,就构造成"用 ...

  8. jenkins组权限_Jenkins 中基于角色的权限管理

    !版权声明:本博客内容均均为原创,每篇博文作为知识积累,写博不易,转载请注明出处. 目录[-] 系统环境: Jenkins 版本:2.213 一.简介 Jenkins 一般应用于项目构建与持续集成中, ...

  9. 【概念】权限管理模型(RBAC、ABAC、ACL)

    目录 1.RABC模型 2. ABAC 模型 3. ACL模型 4. 总结 在管理系统中会涉及到很多用户权限相关问题,对于不同的平台所使用的的权限管理模型也是多样的. 1.RABC模型 该模型是基于角 ...

最新文章

  1. python五十:反射
  2. Multi-Scale Densenet续作?搞定Transformer降采样,清华联合华为开源动态ViT!
  3. Java Web之BaseServlet的抽取
  4. [react] 怎样在react中创建一个事件?
  5. 如何让linux服务器同步互联网时间
  6. C中的volatile用法
  7. c++实现LSTM,ADAM优化,预测大写数字
  8. Window图片和传真查看器不能用
  9. 百度大脑开放日走进厦门 全面解析AI如何赋能企业服务智能化
  10. 多层板的板层布局和线宽的设置(记录)
  11. 原生js-购物车案例(四)增减商品数量,小计价格计算
  12. Python教程三:使用Flask搭建web服务
  13. Web 动画帧率(FPS)计算
  14. “word在试图打开文件时遇到错误”解决办法,亲测可用
  15. 自动化设备数据采集系统优势
  16. 异地远程连接在家里的群晖NAS【无公网IP,免费内网穿透】
  17. 5GNR漫谈9:PDSCH和PUSCH资源映射(频域type0/type1和时域typeA/typeB/typeC)
  18. oracle 表空间文件达到32G后解决办法
  19. 做一个小程序大概需要多少钱?一般小程序要多少钱?
  20. iOS VS Android ,10年之战,谁是最后赢家?

热门文章

  1. 菜鸟学UML--概述
  2. SubSonic中RecordBaseT.Load(IDataReader dataReader)与LoadAndCloseReader(IDataReader dataReader)的使用区别...
  3. c#中使用消息循环机制发送接收字符串的方法和数据类型转换
  4. C#中的bitmap类和图像像素值获取方法
  5. c++用WinForm做界面的实现
  6. AFN框架和SDWebImage框架的上手体验
  7. qt 设置按钮大小_Qt官方示例双向按钮
  8. java 监听本地端口_JAVA本地监听与远程端口扫描
  9. 编程判断元素归类_如何使用jquery判断一个元素是否含有一个指定的类(class)...
  10. 拦截retrofit数据请求返回的信息来判断程序错误点