1 /******************************************/2 /*Name: Rights Management*/3 /*Date Written: 2010.5.20*/4 /*Developer: Dangqinghua*/ 5 /*****************************************/6 --Create Database Grop7 --Go8 UseGrop9 GoTen -----Create a user table One Create TableUsers A ( -u_idint Identity(1,1)Primary Key, -Unamevarchar( -) not NULL, the ) - Go - ----Create a role table - Create TableRoles + ( -role_idint Identity(1,1)Primary Key, +Role_namevarchar( -) not NULL, ARloe_descriptionvarchar( -)NULL,/*Role Notes*/ at ) - Go - ----Create permission table - Create Table Fun - ( -fun_idint Identity(1,1)Primary Key, inFun_namevarchar( -) not NULL, - ) to Go + ---Create a User role table - Create TableUsersrole the ( *Users_roleint Identity(1,1)Primary Key, $u_idint Foreign Key ReferencesUsers (u_id),Panax Notoginsengrole_idint Foreign Key ReferencesRoles (role_id), - ) the Go + ----Create a role permission table A Create TableFunrole the ( +funrole_idint Identity(1,1)Primary Key, -fun_idint Foreign Key ReferencesFun (fun_id), $role_idint Foreign Key ReferencesRoles (role_id), $ ) - Go - Insert intoUsersValues('111') the Insert intoUsersValues('Zhang San') - Insert intoUsersValues('John Doe')Wuyi Insert intoUsersroleValues(1,1) the Insert intoUsersroleValues(2,1) - Insert intoRolesValues('System Users','Column Management') Wu Insert intoRolesValues('Administrator','Management Background') - Insert intoRolesValues('Super Management','So permissions') About Insert intoFunroleValues(1,1) $ Insert intoFunroleValues(2,2) - Insert intoFunValues('New') - Insert intoFunValues('Edit') - Insert intoFunroleValues(1,1) A Insert intoFunroleValues(1,2) + Select * fromRoles the Select * fromUsersrole - Select * fromUsers $ Select * from Fun the Select * fromFunrole theCollection in .- -- -
SQL script create user role Permissions table