文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>轻松掌握用户,角色,功能之间的关系视图

轻松掌握用户,角色,功能之间的关系视图

时间:2008-03-23  来源:sdccf

来源:赛迪    作者:36331

用户,角色,功能之间的关系视图:

假设你目前有下面的数据库结构:

create table userinfo(id varchar(20),name varchar(20)); create table roleinfo(id varchar(20),name varchar(20)); create table functioninfo(id varchar(20),name varchar(20)); create table userrole(userid varchar(20),roleid varchar(20)); create table rolefunction(roleid varchar(20),functionid varchar(20)); insert into userinfo values("1","gao1"); insert into userinfo values("2","gao2"); insert into userinfo values("3","gao3"); insert into roleinfo values("1","role1"); insert into roleinfo values("2","role2"); insert into roleinfo values("3","role3"); insert into functioninfo values("1","function1"); insert into functioninfo values("2","function2"); insert into functioninfo values("3","function3"); insert into userrole values("1","1"); insert into userrole values("1","2"); insert into userrole values("2","2"); insert into userrole values("3","1"); insert into userrole values("3","2"); insert into userrole values("3","3"); insert into role function values("1","1"); insert into role function values("1","2"); insert into role function values("2","2"); insert into role function values("3","1"); insert into role function values("3","2"); insert into role function values("3","3");

你可以根据三者连接的结果建立视图,得出整个权限模型的数据。

select u.name as username,r.name as rolename,f.name as functionname from userrole ur inner join userinfo u on ur.userid=u.id inner join roleinfo r on ur.roleid=r.id inner join rolefunction rf on rf.roleid=r.id inner join functioninfo f on rf.functionid=f.id order by u.name;

结果如下:

相关阅读 更多 +
排行榜 更多 +
找茬脑洞的世界安卓版

找茬脑洞的世界安卓版

休闲益智 下载
滑板英雄跑酷2手游

滑板英雄跑酷2手游

休闲益智 下载
披萨对对看下载

披萨对对看下载

休闲益智 下载