/*--软件权限设置的例子--*/CREATE TABLE 功能 (
id int IDENTITY (1, 1),
功能名称 nvarchar (50),
parentid int
)
GOCREATE TABLE 用户 (
id int IDENTITY (1, 1) NOT NULL,
用户名 nvarchar (50),
密码 nvarchar (50),
修改日期 datetime,
起始日期 datetime
)
GOCREATE TABLE 权限 (
id int IDENTITY (1, 1) NOT NULL,
用户ID int,
功能id int,
操作权限,
)
GO--数据
--软件的功能分类
insert into 功能
select '产品销售',0
union all select '电器',1
union all select '食品类',1
union all select '日常用品',1
union all select '家电',2
union all select '电脑',2--用户
insert into 用户
select '张三',null,getdate(),getdate()
union all select '李四',null,getdate(),getdate()--权限分配,假设每个功能都有这样的权限设置:1.新增/2.修改/3.删除/4.打印
insert into 权限
select 1,2,power(2,1)+power(2,2)+power(2,4)  --张三具有电器类的1.新增/2.修改/4.打印的功能
select 1,4,power(2,1)+power(2,2) --张三具有日常用品类的1.新增/2.修改的功能
select 2,1,power(2,1)+power(2,2)+power(2,3)+power(2,4)  --李四具有所有权限