对于权限、角色、组、用户之间的关系,四者之间均是多对多的关系:
<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /><shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"><stroke joinstyle="miter"></stroke><formulas><f eqn="if lineDrawn pixelLineWidth 0"></f><f eqn="sum @0 1 0"></f><f eqn="sum 0 0 @1"></f><f eqn="prod @2 1 2"></f><f eqn="prod @3 21600 pixelWidth"></f><f eqn="prod @3 21600 pixelHeight"></f><f eqn="sum @0 0 1"></f><f eqn="prod @6 1 2"></f><f eqn="prod @7 21600 pixelWidth"></f><f eqn="sum @8 21600 0"></f><f eqn="prod @7 21600 pixelHeight"></f><f eqn="sum @10 21600 0"></f></formulas><path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"></path><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><lock v:ext="edit" aspectratio="t"></lock></shapetype><shape id="图片_x0020_1" style="VISIBILITY: visible; WIDTH: 415.5pt; HEIGHT: 287.25pt" o:spid="_x0000_i1025" type="#_x0000_t75"><imagedata src="file:///C:/DOCUME~1/CHAICH~1.ASU/LOCALS~1/Temp/msohtmlclip1/01/clip_image001.jpg" o:title="r_%e6%9d%83%e9%99%90%e7%ae%a1%e7%90%86%e5%af%b9%e8%b1%a1%e5%9b%be"></imagedata></shape>
设计的原则:数据是数据,关系是关系。
1. 要求:
用户、客户、员工,这三者是一种继承的关系。分配角色,赋予不同的权限。
下面的设计并没有引入“组”的概念,只是涉及用户、权限、角色三者。
2. 数据库设计中实体表:
1) 用户表 user
2) 角色 role
3) 权限 permission
3. 关系表:
1) 用户角色表
userRole
2) 角色权限表
rolePermission
下面是使用PowerDesigner设计的PDM图:
主外键关系命名:
Fk_parent_<主键>_child_<外键>
表关系建立原则:
Table A 字段: aid(主键)
Table B 字段: bid(主键)
1. 一对一
Table A
Table B 分别设置各自的主键
2. 一对多(A对B:1-n)
Table B中设置外键 aid
3. 多对多
必须设置一张单独的关系表
Table C 中设置外键 aid bid
下面是使用PowerDesigner设计后生成的SQL Server 2005脚本文件:
/*==============================================================*/
/* DBMS name: Microsoft SQL Server 2005 */
/* Author: ChaiChunyan
/* Created on: 2008-11-11 20:28:05 */
/*==============================================================*/
if exists (select 1
from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
where r.fkeyid = object_id('RolePermission') and o.name = 'FK_ROLEPERM_FK_PERMIS_PERMISSI')
alter table RolePermission
drop constraint FK_ROLEPERM_FK_PERMIS_PERMISSI
go
if exists (select 1
from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
where r.fkeyid = object_id('RolePermission') and o.name = 'FK_ROLEPERM_FK_ROLE_R_ROLE')
alter table RolePermission
drop constraint FK_ROLEPERM_FK_ROLE_R_ROLE
go
if exists (select 1
from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
where r.fkeyid = object_id('customer') and o.name = 'FK_CUSTOMER_FK_USER_I_USER')
alter table customer
drop constraint FK_CUSTOMER_FK_USER_I_USER
go
if exists (select 1
from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
where r.fkeyid = object_id('employee') and o.name = 'FK_EMPLOYEE_FK_USER_I_USER')
alter table employee
drop constraint FK_EMPLOYEE_FK_USER_I_USER
go
if exists (select 1
from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
where r.fkeyid = object_id('guest') and o.name = 'FK_GUEST_FK_USER_I_USER')
alter table guest
drop constraint FK_GUEST_FK_USER_I_USER
go
if exists (select 1
from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
where r.fkeyid = object_id('userRole') and o.name = 'FK_USERROLE_FK_ROLE_R_ROLE')
alter table userRole
drop constraint FK_USERROLE_FK_ROLE_R_ROLE
go
if exists (select 1
from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
where r.fkeyid = object_id('userRole') and o.name = 'FK_USERROLE_FK_USER_I_USER')
alter table userRole
drop constraint FK_USERROLE_FK_USER_I_USER
go
if exists (select 1
from sysobjects
where id = object_id('Permission')
and type = 'U')
drop table Permission
go
if exists (select 1
from sysobjects
where id = object_id('RolePermission')
and type = 'U')
drop table RolePermission
go
if exists (select 1
from sysobjects
where id = object_id('customer')
and type = 'U')
drop table customer
go
if exists (select 1
from sysobjects
where id = object_id('employee')
and type = 'U')
drop table employee
go
if exists (select 1
from sysobjects
where id = object_id('guest')
and type = 'U')
drop table guest
go
if exists (select 1
from sysobjects
where id = object_id('role')
and type = 'U')
drop table role
go
if exists (select 1
from sysobjects
where id = object_id('"user"')
and type = 'U')
drop table "user"
go
if exists (select 1
from sysobjects
where id = object_id('userRole')
and type = 'U')
drop table userRole
go
/*==============================================================*/
/* Table: Permission */
/*==============================================================*/
create table Permission (
ID int not null,
Name nvarchar(64) null,
constraint PK_PERMISSION primary key (ID)
)
go
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'权限',
'user', @CurrentUser, 'table', 'Permission'
go
/*==============================================================*/
/* Table: RolePermission */
/*==============================================================*/
create table RolePermission (
roleID int not null,
permissionID int not null,
constraint PK_ROLEPERMISSION primary key (roleID, permissionID)
)
go
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'授权',
'user', @CurrentUser, 'table', 'RolePermission'
go
/*==============================================================*/
/* Table: customer */
/*==============================================================*/
create table customer (
customerID int not null,
customerName varchar(64) null,
companyName varchar(64) null,
oder varchar(64) null,
constraint PK_CUSTOMER primary key (customerID)
)
go
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'客户',
'user', @CurrentUser, 'table', 'customer'
go
/*==============================================================*/
/* Table: employee */
/*==============================================================*/
create table employee (
employeeID int not null,
employeeName varchar(64) null,
sex int null,
age int null,
Department varchar(64) null,
constraint PK_EMPLOYEE primary key (employeeID)
)
go
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'员工',
'user', @CurrentUser, 'table', 'employee'
go
/*==============================================================*/
/* Table: guest */
/*==============================================================*/
create table guest (
guestID int not null,
guestName nvarchar(64) null,
constraint PK_GUEST primary key (guestID)
)
go
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'访客',
'user', @CurrentUser, 'table', 'guest'
go
/*==============================================================*/
/* Table: role */
/*==============================================================*/
create table role (
roleID int not null,
roleName varchar(64) null,
constraint PK_ROLE primary key (roleID)
)
go
/*==============================================================*/
/* Table: "user" */
/*==============================================================*/
create table "user" (
ID int not null,
Name varchar(20) null,
Password varchar(20) null,
constraint PK_USER primary key (ID)
)
go
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'用户数据表',
'user', @CurrentUser, 'table', 'user'
go
/*==============================================================*/
/* Table: userRole */
/*==============================================================*/
create table userRole (
userID int not null,
roleID int not null,
constraint PK_USERROLE primary key (userID, roleID)
)
go
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'用户角色关系表',
'user', @CurrentUser, 'table', 'userRole'
go
alter table RolePermission
add constraint FK_ROLEPERM_FK_PERMIS_PERMISSI foreign key (permissionID)
references Permission (ID)
go
alter table RolePermission
add constraint FK_ROLEPERM_FK_ROLE_R_ROLE foreign key (roleID)
references role (roleID)
go
alter table customer
add constraint FK_CUSTOMER_FK_USER_I_USER foreign key (customerID)
references "user" (ID)
go
alter table employee
add constraint FK_EMPLOYEE_FK_USER_I_USER foreign key (employeeID)
references "user" (ID)
go
alter table guest
add constraint FK_GUEST_FK_USER_I_USER foreign key (guestID)
references "user" (ID)
go
alter table userRole
add constraint FK_USERROLE_FK_ROLE_R_ROLE foreign key (roleID)
references role (roleID)
go
alter table userRole
add constraint FK_USERROLE_FK_USER_I_USER foreign key (userID)
references "user" (ID)
go
分享到:
相关推荐
要求具备基本功能如下: (1)能够对角色信息进行添加、修改、删除、浏览等操作; (2)能够对权限信息进行添加、...(3)实现对角色的权限分配与管理; (4)系统操作简单,方便实用。 数据库在database文件夹中!
这是基于SpringBoot和Shiro实现的一个角色权限访问控制(RBAC)的系统。 基本描述 : 1 . 一个用户具有一个角色,或者多个角色 2 . 一个角色具有一个权限,或者多个权限 3 . 权限可以访问对应的api,或者url...
基于角色的访问控制:对于在网站环境中的访问控制方法,基于角色的访问控制方法(RBAC)是目前公认的解决.RBAC模型广泛应用于当前的数据库系统存取控制,以提供相对于DAC和MAC较好的安全.角色访问控制(RBAC)引入了Role...
指出在设计该安全机制时,应首先创建全局组,通过SQL Server Users组获得服务器访问,通过具体数据库组获得数据库访问权限,然后根据用户访问需求创建数据库角色并对角色分配权限,最后全局组通过加入角色获得权限,从而可...
研究和探讨了实际应用中的用户权限及访问...实践表明,基于角色访问控制的权限访问控制系统能严格地控制与防止用户接触与其身份角色不相关的数据信息,有效地避免用户的非法操作,从而切实地提高系统的可用性和健壮性。
Control的缩写,意思就是基于角色的权限访问控制。 基本思想: 对系统的各种权限不是直接授予具体的用户,而是在用户集合与权限集合之间建立一个角色集合。每一种角色对应一组相应的权限。一旦用户被分配了适当的...
AuthX 是一个简单、易用的开源权限管理...它旨在帮助开发者轻松地实现基于角色的访问控制(RBAC)和权限管理。简单易用的 API 接口,支持多种数据库存储,可扩展的权限管理策略,高性能和高可用性,完善的文档和示例
授权-具有数据库持久性的基于角色的访问控制(RBAC)Go程序包具有数据库持久性的基于角色的访问控制(RBAC)Go程序包功能创建角色创建权限为角色分配权限为用户分配多个角色检查用户的角色检查用户的权限检查角色的...
基于角色的权限访问控制RBCA(Role-Based Access Control) Spring+Springmvc+Mybatis三大框架 Ajax技术 springmvc文件上传 shiro安全框架 Redis缓存 JavaMail邮件 基于aop切面的日志管理 Layui前端框架 登录验证码 ...
题目1:自主访问控制实验;...(5) 对用户的角色信息进行修改,通过访问控制实验,体现不同层次的角色访问权限的差别 (6) 对上述实验情况下访问成功和不成功的两种情形均给出结果 写的不是很好,仅供参考。
java基于Servlet实现的增删改查角色权限控制系统,内有各种文档,项目原型,设计流程图,数据库原型,基于mySql实现我的大学小卖铺。请勿用于商业用途。
本系统采用了基于角色的访问控制,角色和菜单关联,一个角色可以配置多个菜单权限;然后再将用户和角色关联,一位用户可以赋予多个角色。这样用户就可以根据角色拿到该有的菜单权限,更方便管理者进行权限管控。
本系统采用了基于角色的访问控制,角色和菜单关联,一个角色可以配置多个菜单权限;然后再将用户和角色关联,一位用户可以赋予多个角色。这样用户就可以根据角色拿到该有的菜单权限,更方便管理者进行权限管控。
基于角色的访问控制(RBAC) 许多基于角色的访问控制(RBAC)的实现方式有所不同,但是由于它模拟了现实生活中的角色(职位)分配,因此基础知识被广泛采用。 但是,尽管数据变得越来越复杂; 您需要定义关于资源,...
预约挂号系统采用了基于角色的访问控制,角色和菜单关联,一个角色可以配置多个菜单权限;然后再将用户和角色关联,一位用户可以赋予多个角色。这样用户就可以根据角色拿到该有的菜单权限,更方便医院管理人员进行...
统一角色访问控制系统(Unified Role Access Control System),是基于Spring Security 3实现的权限控制系统 程序框架版本说明:Spring MVC 3.0.6 Spring Security 3.1.3 Hibernate 3.6.10 运行演示例子: ...
- 实现角色管理功能,包括角色创建、角色权限分配等。 - 实现权限管理功能,包括权限创建、权限分配等。 4. 前端开发: - 使用前端框架(如Vue、React等)搭建前端框架。 - 设计并实现用户登录、注册页面。 - ...
超市账单管理系统采用了基于角色的访问控制,角色和菜单关联,一个角色可以配置多个菜单权限;然后再将用户和角色关联,一位用户可以赋予多个角色。这样用户就可以根据角色拿到该有的菜单权限,更方便小型超市的管理...
这是一个基于mysql的数据库设计,包含用户、角色、权限、用户组及其关系的数据库设计,适用于比较常见的就是基于角色的访问控制,用户通过角色与权限进行关联。简单地说,一个用户拥有多个角色,一个角色拥有多个...
还包含系统自带的用户管理、部门管理、角色管理、菜单管理、日志管理、数据字典管理、文件管理、图表展示等基础模块,高校学生管理系统基于角色的访问控制,给教务管理员、教师、学生使用,可将权限精确到按钮级别,...