創(chuàng)建SQL角色與權(quán)限用到的五個數(shù)據(jù)庫表
作者:佚名
SQL角色創(chuàng)建以及授權(quán)的時候,需要用到一些表,下面就為您介紹這些表的創(chuàng)建腳本,供您參考學(xué)習(xí)。
下文為您列舉的五張表是在創(chuàng)建SQL角色與權(quán)限時需要用到的,如果您在創(chuàng)建SQL角色等方面遇到過問題,不妨一看,對您會有所啟迪。
創(chuàng)建SQL角色與權(quán)限要用到五張數(shù)據(jù)庫表:
1,SQL用戶信息表
- 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,SQL角色表
- create table role
- (
- roleid varchar(50) not null, --角色Id
- rolename varchar(100), --角色名稱
- )
- alter table tole --主鍵
- add constraint pk_role_roleid primary key (roleid)
3,SQL權(quán)限表
- create table popedom
- (
- popedomid int identity(1,1) not null, --權(quán)限Id
- popedomname varchar(100), --權(quán)限名稱
- popedomfatherid int, --權(quán)限父ID
- popedomurl varchar(100) --樹的連接路徑
- ..
- ..
- )
- er table popedom --主鍵
- add constraint PK_popedom primary key (popedomid)
添加數(shù)據(jù)如
insert into popedom values('我的辦公桌',0,'')
insert into popedom values('電子郵箱',1,'../mail/EmaiolManage.aspx')
(添加數(shù)據(jù)的原則是一級接點的popedomfatherid 為0,如果是(我的辦公桌)下面的接點,它們的popedomfatherid為(我的辦公桌)的主鍵)
4,用戶與角色關(guān)系表
- create table user_role
- (
- connectionid int identity(1,1) not null, --關(guān)系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,角色與權(quán)限關(guān)系表
- create table role_popedom --角色與權(quán)限表
- (
- connectionid int identity(1,1), --關(guān)系Id
- roleid varchar(50) not null, --角色ID
- popedomid int not null, --權(quán)限Id
- popedom int --權(quán)限 (1為可用,2為不可用)
- )
- alter table role_popedom --主鍵
- add constraint PK_role_popedom primary key(connectionid) --主鍵
【編輯推薦】
責(zé)任編輯:段燃
來源:
互聯(lián)網(wǎng)