'FK_USERROLE_FK_ROLE_R_ROLE') alter table userRole
drop constraint FK_USERROLE_FK_ROLE_R_ROLE go
if exists (select 1
from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
where r.fkeyid = object_id('userRole') and o.name = 'FK_USERROLE_FK_USER_I_USER') alter table userRole
drop constraint FK_USERROLE_FK_USER_I_USER go
if exists (select 1
from sysobjects
where id = object_id('Permission') and type = 'U') drop table Permission go
if exists (select 1
from sysobjects
where id = object_id('RolePermission') and type = 'U')
drop table RolePermission go
if exists (select 1
from sysobjects
where id = object_id('customer') and type = 'U') drop table customer go
if exists (select 1
from sysobjects
where id = object_id('employee') and type = 'U') drop table employee go
if exists (select 1
from sysobjects
where id = object_id('guest') and type = 'U') drop table guest go
if exists (select 1
from sysobjects
where id = object_id('role') and type = 'U') drop table role go
if exists (select 1
from sysobjects
where id = object_id('\ and type = 'U') drop table \go
if exists (select 1
from sysobjects
where id = object_id('userRole') and type = 'U') drop table userRole go
/*==============================================================*/
/* Table: Permission */
/*==============================================================*/
create table Permission (
ID int not null, Name nvarchar(64) null, constraint PK_PERMISSION primary key (ID) ) go
declare @CurrentUser sysname select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', '权限',
'user', @CurrentUser, 'table', 'Permission' go
/*==============================================================*/
/* Table: RolePermission */
/*==============================================================*/ create table RolePermission (
roleID int not null, permissionID int not null, constraint PK_ROLEPERMISSION primary key (roleID,
permissionID) ) go
declare @CurrentUser sysname select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', '授权',
'user', @CurrentUser, 'table', 'RolePermission' go
/*==============================================================*/
/* Table: customer */
/*==============================================================*/ create table customer (
customerID int not null, customerName varchar(64) null, companyName varchar(64) null, oder varchar(64) null, constraint PK_CUSTOMER primary key (customerID) )