权限数据库设计(Sql Server)

个人总结,仅供参考!!!适合做小型网站时用!!!
创建角色与权限要用到五张数据库表:
1,用户信息表
create table employee
(
   userid varchar(50) not null,  --用户ID
   username varchar(100),    --用户名
   userpassword varchar(100), --密码
   ..
   ..
   ..
   ..
)
alter table employee        --主键
add constraint pk_employee_userid primary key (userid)
2,角色表
create table role
(
  roleid varchar(50) not null, --角色Id
  rolename varchar(100),        --角色名称
)
alter table tole     --主键
add constraint pk_role_roleid primary key (roleid)
3,权限表
create table popedom
(
  popedomid int identity(1,1) not null, --权限Id
  popedomname varchar(100), --权限名称
  popedomfatherid int,      --权限父ID
  popedomurl varchar(100)   --树的连接路径
  ..
  ..

er table popedom       --主键
add constraint PK_popedom primary key (popedomid)

添加数据如
insert into popedom values('我的办公桌',0,'')
insert into popedom values('电子邮箱',1,'../mail/EmaiolManage.aspx')
(添加数据的原则是一级接点的popedomfatherid 为0,如果是(我的办公桌)下面的接点,它们的popedomfatherid为(我的办公桌)的主键)

4,用户与角色关系表
create table user_role
(
 connectionid int identity(1,1) not null, --关系ID
  userid varchar(50) not null,   --管理员表ID
  roleid varchar(50) not null   --角色Id
)
alter table user_role    --主键
add constraint PK_admin_role primary key(connectionid)
5,角色与权限关系表
create table role_popedom     --角色与权限表
(
  connectionid int identity(1,1), --关系Id
  roleid varchar(50) not null,      --角色ID
  popedomid int not null,   --权限Id
  popedom    int   --权限 (1为可用,2为不可用)
)
alter table role_popedom       --主键
add constraint PK_role_popedom primary key(connectionid) --主键

1.用户信息表是用户基本信息表。
2.角色表是系统中所用到的角色,如系统管理员,总经理……
3.权限表这里建立的是树型结构的,一般都是后台系统管理员管理的那棵树。
4.用户与角色关系表是把用户和角色建立一种关系。
5.角色与权限关系表是角色与权限建立一种关系。

转载于:https://www.cnblogs.com/factly/archive/2008/06/28/1231595.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值