标签:
1 USE [AirCRM] 2 GO 3 4 /****** Object: Table [dbo].[CRM_Department] Script Date: 2015/4/9 16:36:09 ******/ 5 SET ANSI_NULLS ON 6 GO 7 8 SET QUOTED_IDENTIFIER ON 9 GO 10 11 CREATE TABLE [dbo].[CRM_Department]( 12 [ID] [int] IDENTITY(1,1) NOT NULL, 13 [DepartmentGUID] [uniqueidentifier] ROWGUIDCOL NOT NULL, 14 [DepartmentName] [nvarchar](100) NOT NULL, 15 [DepartmentAliasName] [nvarchar](50) NULL, 16 [DepartmentStatus] [bit] NOT NULL, 17 [DepartmentParentGUID] [uniqueidentifier] NULL, 18 [DepartmentDescription] [nvarchar](250) NULL, 19 [DepartmentManagerGUID] [uniqueidentifier] NULL, 20 [DepartmentTypeGUID] [uniqueidentifier] NULL, 21 [DepartmetnOrganizationGUID] [uniqueidentifier] NULL, 22 CONSTRAINT [PK_CRM_Department] PRIMARY KEY CLUSTERED 23 ( 24 [DepartmentGUID] ASC 25 )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] 26 ) ON [PRIMARY] 27 28 GO 29 30 ALTER TABLE [dbo].[CRM_Department] ADD CONSTRAINT [DF_CRM_Department_DepartmentGUID] DEFAULT (newid()) FOR [DepartmentGUID] 31 GO 32 33 ALTER TABLE [dbo].[CRM_Department] WITH CHECK ADD CONSTRAINT [FK_CRM_Department_CRM_Department] FOREIGN KEY([DepartmentParentGUID]) 34 REFERENCES [dbo].[CRM_Department] ([DepartmentGUID]) 35 GO 36 37 ALTER TABLE [dbo].[CRM_Department] CHECK CONSTRAINT [FK_CRM_Department_CRM_Department] 38 GO 39 40 ALTER TABLE [dbo].[CRM_Department] WITH CHECK ADD CONSTRAINT [FK_CRM_Department_CRM_Organization] FOREIGN KEY([DepartmetnOrganizationGUID]) 41 REFERENCES [dbo].[CRM_Organization] ([OrganizationGUID]) 42 GO 43 44 ALTER TABLE [dbo].[CRM_Department] CHECK CONSTRAINT [FK_CRM_Department_CRM_Organization] 45 GO 46 47 ALTER TABLE [dbo].[CRM_Department] WITH CHECK ADD CONSTRAINT [FK_CRM_Department_CRM_Person] FOREIGN KEY([DepartmentManagerGUID]) 48 REFERENCES [dbo].[CRM_Person] ([PersonGUID]) 49 GO 50 51 ALTER TABLE [dbo].[CRM_Department] CHECK CONSTRAINT [FK_CRM_Department_CRM_Person] 52 GO 53 54 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘组织机构-部门编号‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Department‘, @level2type=N‘COLUMN‘,@level2name=N‘ID‘ 55 GO 56 57 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘组织机构-部门GUID‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Department‘, @level2type=N‘COLUMN‘,@level2name=N‘DepartmentGUID‘ 58 GO 59 60 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘组织机构-部门名称‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Department‘, @level2type=N‘COLUMN‘,@level2name=N‘DepartmentName‘ 61 GO 62 63 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘组织机构-部门别名‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Department‘, @level2type=N‘COLUMN‘,@level2name=N‘DepartmentAliasName‘ 64 GO 65 66 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘组织机构-状态(0:启用,1:禁用)‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Department‘, @level2type=N‘COLUMN‘,@level2name=N‘DepartmentStatus‘ 67 GO 68 69 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘上一级部门GUID‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Department‘, @level2type=N‘COLUMN‘,@level2name=N‘DepartmentParentGUID‘ 70 GO 71 72 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘组织机构-部门说明‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Department‘, @level2type=N‘COLUMN‘,@level2name=N‘DepartmentDescription‘ 73 GO 74 75 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘部门管理者GUID‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Department‘, @level2type=N‘COLUMN‘,@level2name=N‘DepartmentManagerGUID‘ 76 GO 77 78 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘组织机构-部门类型GUID‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Department‘, @level2type=N‘COLUMN‘,@level2name=N‘DepartmentTypeGUID‘ 79 GO 80 81 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘部门所属组织机构GUID‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Department‘, @level2type=N‘COLUMN‘,@level2name=N‘DepartmetnOrganizationGUID‘ 82 GO
1 USE [AirCRM] 2 GO 3 4 /****** Object: Table [dbo].[CRM_Menu] Script Date: 2015/4/9 17:04:24 ******/ 5 SET ANSI_NULLS ON 6 GO 7 8 SET QUOTED_IDENTIFIER ON 9 GO 10 11 CREATE TABLE [dbo].[CRM_Menu]( 12 [ID] [int] IDENTITY(1,1) NOT NULL, 13 [MenuGUID] [uniqueidentifier] ROWGUIDCOL NOT NULL, 14 [MenuName] [nvarchar](50) NOT NULL, 15 [MenuItemCaption] [nvarchar](50) NOT NULL, 16 [MenuItemCaptionEnglish] [nvarchar](50) NULL, 17 [IsParentMenuItem] [bit] NOT NULL, 18 [MenuItemICON] [nvarchar](50) NULL, 19 [MenuItemStatus] [bit] NULL, 20 [MenuItemUrl] [nvarchar](250) NULL, 21 [MenuItemType] [nvarchar](150) NULL, 22 [MenuParentGUID] [uniqueidentifier] NULL, 23 CONSTRAINT [PK_CRM_Menu] PRIMARY KEY CLUSTERED 24 ( 25 [MenuGUID] ASC 26 )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] 27 ) ON [PRIMARY] 28 29 GO 30 31 ALTER TABLE [dbo].[CRM_Menu] ADD CONSTRAINT [DF_CRM_Menu_MenuGUID] DEFAULT (newid()) FOR [MenuGUID] 32 GO 33 34 ALTER TABLE [dbo].[CRM_Menu] WITH CHECK ADD CONSTRAINT [FK_CRM_Menu_CRM_Menu] FOREIGN KEY([MenuParentGUID]) 35 REFERENCES [dbo].[CRM_Menu] ([MenuGUID]) 36 GO 37 38 ALTER TABLE [dbo].[CRM_Menu] CHECK CONSTRAINT [FK_CRM_Menu_CRM_Menu] 39 GO 40 41 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘菜单GUID‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Menu‘, @level2type=N‘COLUMN‘,@level2name=N‘MenuGUID‘ 42 GO 43 44 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘菜单名称‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Menu‘, @level2type=N‘COLUMN‘,@level2name=N‘MenuName‘ 45 GO 46 47 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘菜单标题‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Menu‘, @level2type=N‘COLUMN‘,@level2name=N‘MenuItemCaption‘ 48 GO 49 50 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘菜单项英文标题‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Menu‘, @level2type=N‘COLUMN‘,@level2name=N‘MenuItemCaptionEnglish‘ 51 GO 52 53 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘是否为父级菜单‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Menu‘, @level2type=N‘COLUMN‘,@level2name=N‘IsParentMenuItem‘ 54 GO 55 56 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘菜单图标‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Menu‘, @level2type=N‘COLUMN‘,@level2name=N‘MenuItemICON‘ 57 GO 58 59 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘菜单项状态(0:启用,1:禁用)‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Menu‘, @level2type=N‘COLUMN‘,@level2name=N‘MenuItemStatus‘ 60 GO 61 62 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘菜单项URL‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Menu‘, @level2type=N‘COLUMN‘,@level2name=N‘MenuItemUrl‘ 63 GO 64 65 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘菜单项类型‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Menu‘, @level2type=N‘COLUMN‘,@level2name=N‘MenuItemType‘ 66 GO 67 68 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘菜单项父菜单GUID‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Menu‘, @level2type=N‘COLUMN‘,@level2name=N‘MenuParentGUID‘ 69 GO
1 USE [AirCRM] 2 GO 3 4 /****** Object: Table [dbo].[CRM_Organization] Script Date: 2015/4/9 16:35:54 ******/ 5 SET ANSI_NULLS ON 6 GO 7 8 SET QUOTED_IDENTIFIER ON 9 GO 10 11 CREATE TABLE [dbo].[CRM_Organization]( 12 [ID] [int] IDENTITY(1,1) NOT NULL, 13 [OrganizationGUID] [uniqueidentifier] ROWGUIDCOL NOT NULL, 14 [OrganizationName] [nvarchar](250) NOT NULL, 15 [OrganizationAliasName] [nvarchar](50) NULL, 16 [OrganizationCode] [nvarchar](50) NULL, 17 [OrganizationAddress] [nvarchar](250) NULL, 18 [OrganizationStatus] [bit] NOT NULL, 19 [OrganizationTypeGUID] [uniqueidentifier] NULL, 20 [OrganizationDescription] [nvarchar](250) NULL, 21 [OrganizationParentGUID] [uniqueidentifier] NULL, 22 CONSTRAINT [PK_CRM_Organization] PRIMARY KEY CLUSTERED 23 ( 24 [OrganizationGUID] ASC 25 )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] 26 ) ON [PRIMARY] 27 28 GO 29 30 ALTER TABLE [dbo].[CRM_Organization] ADD CONSTRAINT [DF_CRM_Organization_OrganizationGUID] DEFAULT (newid()) FOR [OrganizationGUID] 31 GO 32 33 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘组织机构编号‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Organization‘, @level2type=N‘COLUMN‘,@level2name=N‘ID‘ 34 GO 35 36 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘组织机构GUID‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Organization‘, @level2type=N‘COLUMN‘,@level2name=N‘OrganizationGUID‘ 37 GO 38 39 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘组织机构名称‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Organization‘, @level2type=N‘COLUMN‘,@level2name=N‘OrganizationName‘ 40 GO 41 42 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘组织机构别名‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Organization‘, @level2type=N‘COLUMN‘,@level2name=N‘OrganizationAliasName‘ 43 GO 44 45 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘组织机构代码‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Organization‘, @level2type=N‘COLUMN‘,@level2name=N‘OrganizationCode‘ 46 GO 47 48 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘组织机构地址‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Organization‘, @level2type=N‘COLUMN‘,@level2name=N‘OrganizationAddress‘ 49 GO 50 51 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘组织机构状态(0:启用,1:禁用)‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Organization‘, @level2type=N‘COLUMN‘,@level2name=N‘OrganizationStatus‘ 52 GO 53 54 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘组织机构类型GUID‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Organization‘, @level2type=N‘COLUMN‘,@level2name=N‘OrganizationTypeGUID‘ 55 GO 56 57 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘组织机构说明‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Organization‘, @level2type=N‘COLUMN‘,@level2name=N‘OrganizationDescription‘ 58 GO 59 60 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘上一级组织机构GUID‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Organization‘, @level2type=N‘COLUMN‘,@level2name=N‘OrganizationParentGUID‘ 61 GO
1 USE [AirCRM] 2 GO 3 4 /****** Object: Table [dbo].[CRM_Permissons] Script Date: 2015/4/9 17:04:08 ******/ 5 SET ANSI_NULLS ON 6 GO 7 8 SET QUOTED_IDENTIFIER ON 9 GO 10 11 CREATE TABLE [dbo].[CRM_Permissons]( 12 [ID] [int] IDENTITY(1,1) NOT NULL, 13 [PermissionGUID] [uniqueidentifier] ROWGUIDCOL NOT NULL, 14 [PermissionName] [nvarchar](50) NOT NULL, 15 [PermissionDescription] [nvarchar](250) NULL, 16 [PermissionStatus] [bit] NOT NULL, 17 [PermissionOwinerGUID] [nvarchar](max) NULL, 18 [PermissionIsExpire] [bit] NULL, 19 [PermissionValidDate] [date] NULL, 20 [PermissionMenuListGUID] [nvarchar](250) NULL, 21 CONSTRAINT [PK_CRM_Permissons] PRIMARY KEY CLUSTERED 22 ( 23 [PermissionGUID] ASC 24 )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] 25 ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] 26 27 GO 28 29 ALTER TABLE [dbo].[CRM_Permissons] ADD CONSTRAINT [DF_CRM_Permissons_PermissionGUID] DEFAULT (newid()) FOR [PermissionGUID] 30 GO 31 32 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘权限编号‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Permissons‘, @level2type=N‘COLUMN‘,@level2name=N‘ID‘ 33 GO 34 35 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘权限GUID‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Permissons‘, @level2type=N‘COLUMN‘,@level2name=N‘PermissionGUID‘ 36 GO 37 38 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘权限名称‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Permissons‘, @level2type=N‘COLUMN‘,@level2name=N‘PermissionName‘ 39 GO 40 41 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘权限说明‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Permissons‘, @level2type=N‘COLUMN‘,@level2name=N‘PermissionDescription‘ 42 GO 43 44 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘权限状态(0:启用,1:禁用,2:锁定,3:过期)‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Permissons‘, @level2type=N‘COLUMN‘,@level2name=N‘PermissionStatus‘ 45 GO 46 47 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘权限拥有者GUID‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Permissons‘, @level2type=N‘COLUMN‘,@level2name=N‘PermissionOwinerGUID‘ 48 GO 49 50 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘权限是否已过期‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Permissons‘, @level2type=N‘COLUMN‘,@level2name=N‘PermissionIsExpire‘ 51 GO 52 53 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘权限有效日期‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Permissons‘, @level2type=N‘COLUMN‘,@level2name=N‘PermissionValidDate‘ 54 GO 55 56 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘权限对应的菜单GUID‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Permissons‘, @level2type=N‘COLUMN‘,@level2name=N‘PermissionMenuListGUID‘ 57 GO
1 USE [AirCRM] 2 GO 3 4 /****** Object: Table [dbo].[CRM_Role] Script Date: 2015/4/9 16:35:01 ******/ 5 SET ANSI_NULLS ON 6 GO 7 8 SET QUOTED_IDENTIFIER ON 9 GO 10 11 CREATE TABLE [dbo].[CRM_Role]( 12 [ID] [int] IDENTITY(1,1) NOT NULL, 13 [RoleGUID] [uniqueidentifier] ROWGUIDCOL NOT NULL, 14 [RoleName] [nvarchar](50) NOT NULL, 15 [RoleAliasName] [nvarchar](50) NULL, 16 [RoleDescription] [nvarchar](250) NULL, 17 [RoleLevel] [int] NOT NULL, 18 [RoleParentGUID] [uniqueidentifier] NOT NULL, 19 [RolePermissionListGUID] [nvarchar](250) NULL, 20 CONSTRAINT [PK_CRM_Role] PRIMARY KEY CLUSTERED 21 ( 22 [RoleGUID] ASC 23 )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] 24 ) ON [PRIMARY] 25 26 GO 27 28 ALTER TABLE [dbo].[CRM_Role] ADD CONSTRAINT [DF_CRM_Role_RoleGUID] DEFAULT (newid()) FOR [RoleGUID] 29 GO 30 31 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘角色编号‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Role‘, @level2type=N‘COLUMN‘,@level2name=N‘ID‘ 32 GO 33 34 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘角色编号‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Role‘, @level2type=N‘COLUMN‘,@level2name=N‘RoleGUID‘ 35 GO 36 37 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘角色名称‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Role‘, @level2type=N‘COLUMN‘,@level2name=N‘RoleName‘ 38 GO 39 40 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘角色别名‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Role‘, @level2type=N‘COLUMN‘,@level2name=N‘RoleAliasName‘ 41 GO 42 43 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘角色说明‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Role‘, @level2type=N‘COLUMN‘,@level2name=N‘RoleDescription‘ 44 GO 45 46 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘角色级别‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Role‘, @level2type=N‘COLUMN‘,@level2name=N‘RoleLevel‘ 47 GO 48 49 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘上一级角色GUID‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Role‘, @level2type=N‘COLUMN‘,@level2name=N‘RoleParentGUID‘ 50 GO 51 52 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘角色权限清单GUID‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_Role‘, @level2type=N‘COLUMN‘,@level2name=N‘RolePermissionListGUID‘ 53 GO
1 USE [AirCRM] 2 GO 3 4 /****** Object: Table [dbo].[CRM_User] Script Date: 2015/4/9 16:34:25 ******/ 5 SET ANSI_NULLS ON 6 GO 7 8 SET QUOTED_IDENTIFIER ON 9 GO 10 11 CREATE TABLE [dbo].[CRM_User]( 12 [ID] [int] IDENTITY(1,1) NOT NULL, 13 [UserGUID] [uniqueidentifier] ROWGUIDCOL NOT NULL, 14 [UserGroupGUID] [uniqueidentifier] NULL, 15 [UserName] [nvarchar](50) NOT NULL, 16 [UserPassword] [nvarchar](50) NOT NULL, 17 [UserType] [int] NULL, 18 [UserStatus] [bit] NOT NULL, 19 [IsUserRegitry] [bit] NULL, 20 [IsSystemAdd] [bit] NULL, 21 [RegistryDate] [date] NOT NULL, 22 [RegistryMobile] [nvarchar](15) NOT NULL, 23 [RegistryEmail] [nvarchar](250) NULL, 24 [UserLoginCounts] [int] NOT NULL, 25 [UserLastLoginDate] [date] NULL, 26 [UserLastLoginAddress] [nvarchar](50) NULL, 27 [UserLastLoginIP] [nvarchar](50) NULL, 28 [UserPasswordErrorCount] [int] NULL, 29 [UserRegistryQQ] [nvarchar](50) NULL, 30 [UserPermissionListGUID] [nvarchar](250) NULL, 31 [IsExpire] [bit] NOT NULL, 32 [ValidDate] [date] NULL, 33 [UserOperationLog] [nvarchar](max) NULL, 34 [UserRoleGUID] [uniqueidentifier] NULL, 35 CONSTRAINT [PK_CRM_User] PRIMARY KEY CLUSTERED 36 ( 37 [UserGUID] ASC 38 )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] 39 ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] 40 41 GO 42 43 ALTER TABLE [dbo].[CRM_User] ADD CONSTRAINT [DF_Table_1_UserGuid] DEFAULT (newid()) FOR [UserGUID] 44 GO 45 46 ALTER TABLE [dbo].[CRM_User] WITH CHECK ADD CONSTRAINT [FK_CRM_User_CRM_Role] FOREIGN KEY([UserRoleGUID]) 47 REFERENCES [dbo].[CRM_Role] ([RoleGUID]) 48 GO 49 50 ALTER TABLE [dbo].[CRM_User] CHECK CONSTRAINT [FK_CRM_User_CRM_Role] 51 GO 52 53 ALTER TABLE [dbo].[CRM_User] WITH CHECK ADD CONSTRAINT [FK_CRM_User_CRM_UserGroup] FOREIGN KEY([UserGroupGUID]) 54 REFERENCES [dbo].[CRM_UserGroup] ([UserGroupGUID]) 55 GO 56 57 ALTER TABLE [dbo].[CRM_User] CHECK CONSTRAINT [FK_CRM_User_CRM_UserGroup] 58 GO 59 60 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户编号‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_User‘, @level2type=N‘COLUMN‘,@level2name=N‘ID‘ 61 GO 62 63 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户GUID‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_User‘, @level2type=N‘COLUMN‘,@level2name=N‘UserGUID‘ 64 GO 65 66 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户组GUID‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_User‘, @level2type=N‘COLUMN‘,@level2name=N‘UserGroupGUID‘ 67 GO 68 69 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户名‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_User‘, @level2type=N‘COLUMN‘,@level2name=N‘UserName‘ 70 GO 71 72 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户密码‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_User‘, @level2type=N‘COLUMN‘,@level2name=N‘UserPassword‘ 73 GO 74 75 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户类型(0:普通用户,1:客户,2:企业用户,3:系统管理员,4:开发人员,5:测试人员)‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_User‘, @level2type=N‘COLUMN‘,@level2name=N‘UserType‘ 76 GO 77 78 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户状态(0:启用,1:禁用,2:新增,3:锁定,4:已过期)‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_User‘, @level2type=N‘COLUMN‘,@level2name=N‘UserStatus‘ 79 GO 80 81 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户通过WEB自己注册‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_User‘, @level2type=N‘COLUMN‘,@level2name=N‘IsUserRegitry‘ 82 GO 83 84 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘通过系统后台添加‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_User‘, @level2type=N‘COLUMN‘,@level2name=N‘IsSystemAdd‘ 85 GO 86 87 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户注册日期‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_User‘, @level2type=N‘COLUMN‘,@level2name=N‘RegistryDate‘ 88 GO 89 90 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户注册手机号码‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_User‘, @level2type=N‘COLUMN‘,@level2name=N‘RegistryMobile‘ 91 GO 92 93 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户注册邮箱地址‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_User‘, @level2type=N‘COLUMN‘,@level2name=N‘RegistryEmail‘ 94 GO 95 96 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户登陆次数‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_User‘, @level2type=N‘COLUMN‘,@level2name=N‘UserLoginCounts‘ 97 GO 98 99 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户最后登陆时间‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_User‘, @level2type=N‘COLUMN‘,@level2name=N‘UserLastLoginDate‘ 100 GO 101 102 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户最后登陆地址‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_User‘, @level2type=N‘COLUMN‘,@level2name=N‘UserLastLoginAddress‘ 103 GO 104 105 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户最后登陆IP地址‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_User‘, @level2type=N‘COLUMN‘,@level2name=N‘UserLastLoginIP‘ 106 GO 107 108 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户密码错误次数(超过3次自动锁定用户,解锁后才能登陆)‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_User‘, @level2type=N‘COLUMN‘,@level2name=N‘UserPasswordErrorCount‘ 109 GO 110 111 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户注册QQ号码‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_User‘, @level2type=N‘COLUMN‘,@level2name=N‘UserRegistryQQ‘ 112 GO 113 114 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户权限列表‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_User‘, @level2type=N‘COLUMN‘,@level2name=N‘UserPermissionListGUID‘ 115 GO 116 117 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户是否已过期(0:未过期,1:已过期)‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_User‘, @level2type=N‘COLUMN‘,@level2name=N‘IsExpire‘ 118 GO 119 120 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户有效日期(空值为永久有效)‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_User‘, @level2type=N‘COLUMN‘,@level2name=N‘ValidDate‘ 121 GO 122 123 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户操作日志‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_User‘, @level2type=N‘COLUMN‘,@level2name=N‘UserOperationLog‘ 124 GO 125 126 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户的角色GUID‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_User‘, @level2type=N‘COLUMN‘,@level2name=N‘UserRoleGUID‘ 127 GO
1 USE [AirCRM] 2 GO 3 4 /****** Object: Table [dbo].[CRM_UserGroup] Script Date: 2015/4/9 16:34:45 ******/ 5 SET ANSI_NULLS ON 6 GO 7 8 SET QUOTED_IDENTIFIER ON 9 GO 10 11 CREATE TABLE [dbo].[CRM_UserGroup]( 12 [ID] [int] IDENTITY(1,1) NOT NULL, 13 [UserGroupGUID] [uniqueidentifier] ROWGUIDCOL NOT NULL, 14 [UserGroupName] [nvarchar](50) NOT NULL, 15 [UserGroupCreater] [nvarchar](50) NOT NULL, 16 [UserGroupCreateDate] [date] NOT NULL, 17 [UserGroupStatus] [bit] NOT NULL, 18 [UserGroupMembersGUID] [nvarchar](250) NULL, 19 [UserGroupPermissionListGUID] [nvarchar](250) NULL, 20 [UserGroupValidDate] [date] NULL, 21 [UserGroupIsExpire] [bit] NULL, 22 [UserGroupDescription] [nvarchar](250) NULL, 23 [UserGroupRoleGUID] [uniqueidentifier] NULL, 24 CONSTRAINT [PK_CRM_UserGroup] PRIMARY KEY CLUSTERED 25 ( 26 [UserGroupGUID] ASC 27 )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] 28 ) ON [PRIMARY] 29 30 GO 31 32 ALTER TABLE [dbo].[CRM_UserGroup] ADD CONSTRAINT [DF_CRM_UserGroup_UserGroupGUID] DEFAULT (newid()) FOR [UserGroupGUID] 33 GO 34 35 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户组编号‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_UserGroup‘, @level2type=N‘COLUMN‘,@level2name=N‘ID‘ 36 GO 37 38 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户组GUID‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_UserGroup‘, @level2type=N‘COLUMN‘,@level2name=N‘UserGroupGUID‘ 39 GO 40 41 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户组名称‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_UserGroup‘, @level2type=N‘COLUMN‘,@level2name=N‘UserGroupName‘ 42 GO 43 44 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户组创建者‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_UserGroup‘, @level2type=N‘COLUMN‘,@level2name=N‘UserGroupCreater‘ 45 GO 46 47 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户组创建日期‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_UserGroup‘, @level2type=N‘COLUMN‘,@level2name=N‘UserGroupCreateDate‘ 48 GO 49 50 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户组状态(0:启用,1:禁用,2:新增,3:锁定)‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_UserGroup‘, @level2type=N‘COLUMN‘,@level2name=N‘UserGroupStatus‘ 51 GO 52 53 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户组成员GUID‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_UserGroup‘, @level2type=N‘COLUMN‘,@level2name=N‘UserGroupMembersGUID‘ 54 GO 55 56 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户组权限列表GUID‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_UserGroup‘, @level2type=N‘COLUMN‘,@level2name=N‘UserGroupPermissionListGUID‘ 57 GO 58 59 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户组有效期(空值为永久有效)‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_UserGroup‘, @level2type=N‘COLUMN‘,@level2name=N‘UserGroupValidDate‘ 60 GO 61 62 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户组是否已过期‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_UserGroup‘, @level2type=N‘COLUMN‘,@level2name=N‘UserGroupIsExpire‘ 63 GO 64 65 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户组说明‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_UserGroup‘, @level2type=N‘COLUMN‘,@level2name=N‘UserGroupDescription‘ 66 GO 67 68 EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘用户组的角色GUID‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘CRM_UserGroup‘, @level2type=N‘COLUMN‘,@level2name=N‘UserGroupRoleGUID‘ 69 GO
标签:
原文地址:http://www.cnblogs.com/linhongquan/p/5503596.html