/*==============================================================*/
/* DBMS name:      Microsoft SQL Server 2000                    */
/* Created on:     2010-08-23 17:13:21                          */
/*==============================================================*/


if exists (select 1
          from sysobjects
          where id = object_id('t_PRC_DeleteFolder')
          and type = 'TR')
   drop trigger t_PRC_DeleteFolder
go

if exists (select 1
   from dbo.sysreferences r join dbo.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('EntFirend') and o.name = 'FK_ENTFIREN_REFERENCE_ENTFRIEN')
alter table EntFirend
   drop constraint FK_ENTFIREN_REFERENCE_ENTFRIEN
go

if exists (select 1
   from dbo.sysreferences r join dbo.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('P_CategoryPriceTypes') and o.name = 'FK_P_CATEGO_REFERENCE_P_SYSBRA')
alter table P_CategoryPriceTypes
   drop constraint FK_P_CATEGO_REFERENCE_P_SYSBRA
go

if exists (select 1
   from dbo.sysreferences r join dbo.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('P_CustomCategory') and o.name = 'FK_P_CUSTOM_REFERENCE_P_SYSBRA')
alter table P_CustomCategory
   drop constraint FK_P_CUSTOM_REFERENCE_P_SYSBRA
go

if exists (select 1
   from dbo.sysreferences r join dbo.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('P_News') and o.name = 'FK_P_NEWS_REFERENCE_ADNEWSGR')
alter table P_News
   drop constraint FK_P_NEWS_REFERENCE_ADNEWSGR
go

if exists (select 1
   from dbo.sysreferences r join dbo.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('P_PriceAreaPermission') and o.name = 'FK_P_PRICEA_REFERENCE_P_PRODUC_2')
alter table P_PriceAreaPermission
   drop constraint FK_P_PRICEA_REFERENCE_P_PRODUC_2
go

if exists (select 1
   from dbo.sysreferences r join dbo.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('P_PriceAreaPermission') and o.name = 'FK_P_PRICEA_REFERENCE_P_PRODUC')
alter table P_PriceAreaPermission
   drop constraint FK_P_PRICEA_REFERENCE_P_PRODUC
go

if exists (select 1
   from dbo.sysreferences r join dbo.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('P_PriceHistory') and o.name = 'FK_P_PRICEH_REFERENCE_P_PRODUC')
alter table P_PriceHistory
   drop constraint FK_P_PRICEH_REFERENCE_P_PRODUC
go

if exists (select 1
   from dbo.sysreferences r join dbo.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('P_PriceOneselfPermission') and o.name = 'FK_P_PRICEO_REFERENCE_P_PRODUC')
alter table P_PriceOneselfPermission
   drop constraint FK_P_PRICEO_REFERENCE_P_PRODUC
go

if exists (select 1
   from dbo.sysreferences r join dbo.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('P_PriceTypeAreaPermission') and o.name = 'FK_P_PRICET_REFERENCE_P_CATEGO')
alter table P_PriceTypeAreaPermission
   drop constraint FK_P_PRICET_REFERENCE_P_CATEGO
go

if exists (select 1
   from dbo.sysreferences r join dbo.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('P_PriceTypeOneselfPermission') and o.name = 'FK_P_PRICET_REFERENCE_P_CATEGO2')
alter table P_PriceTypeOneselfPermission
   drop constraint FK_P_PRICET_REFERENCE_P_CATEGO2
go

if exists (select 1
   from dbo.sysreferences r join dbo.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('P_PriceViewHistory') and o.name = 'FK_P_PRICEV_REFERENCE_P_PRODUC')
alter table P_PriceViewHistory
   drop constraint FK_P_PRICEV_REFERENCE_P_PRODUC
go

if exists (select 1
   from dbo.sysreferences r join dbo.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('P_ProductPrices') and o.name = 'FK_P_PRODUC_REFERENCE_P_CATEGO')
alter table P_ProductPrices
   drop constraint FK_P_PRODUC_REFERENCE_P_CATEGO
go

if exists (select 1
   from dbo.sysreferences r join dbo.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('P_ProductPrices') and o.name = 'FK_P_PRODUC_REFERENCE_P_PRODUC')
alter table P_ProductPrices
   drop constraint FK_P_PRODUC_REFERENCE_P_PRODUC
go

if exists (select 1
   from dbo.sysreferences r join dbo.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('P_Products') and o.name = 'FK_P_PRODUC_REFERENCE_P_SYSBRA')
alter table P_Products
   drop constraint FK_P_PRODUC_REFERENCE_P_SYSBRA
go

if exists (select 1
   from dbo.sysreferences r join dbo.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('P_SysBrandRelationship') and o.name = 'FK_P_SYSBRA_REFERENCE_P_SYSBRA')
alter table P_SysBrandRelationship
   drop constraint FK_P_SYSBRA_REFERENCE_P_SYSBRA
go

if exists (select 1
   from dbo.sysreferences r join dbo.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('P_SysBrandRelationship') and o.name = 'FK_P_SYSBRA_REFERENCE_P_SYSPRO')
alter table P_SysBrandRelationship
   drop constraint FK_P_SYSBRA_REFERENCE_P_SYSPRO
go

if exists (select 1
   from dbo.sysreferences r join dbo.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('sys_lastUpdates') and o.name = 'FK_SYS_LAST_REFERENCE_SYS_LAST')
alter table sys_lastUpdates
   drop constraint FK_SYS_LAST_REFERENCE_SYS_LAST
go

if exists (select 1
            from  sysobjects
           where  id = object_id('AdNewsGroup')
            and   type = 'U')
   drop table AdNewsGroup
go

if exists (select 1
            from  sysobjects
           where  id = object_id('CategoryRelQuote')
            and   type = 'U')
   drop table CategoryRelQuote
go

if exists (select 1
            from  sysobjects
           where  id = object_id('ComBlackList')
            and   type = 'U')
   drop table ComBlackList
go

if exists (select 1
            from  sysobjects
           where  id = object_id('EntFirend')
            and   type = 'U')
   drop table EntFirend
go

if exists (select 1
            from  sysobjects
           where  id = object_id('EntFriendGroup')
            and   type = 'U')
   drop table EntFriendGroup
go

if exists (select 1
            from  sysobjects
           where  id = object_id('FriendChatMemo')
            and   type = 'U')
   drop table FriendChatMemo
go

if exists (select 1
            from  sysobjects
           where  id = object_id('OutsideSeat')
            and   type = 'U')
   drop table OutsideSeat
go

if exists (select 1
            from  sysobjects
           where  id = object_id('P_AreaRestrict')
            and   type = 'U')
   drop table P_AreaRestrict
go

if exists (select 1
            from  sysobjects
           where  id = object_id('P_BrandResponsible')
            and   type = 'U')
   drop table P_BrandResponsible
go

if exists (select 1
            from  sysobjects
           where  id = object_id('P_CategoryPriceTypes')
            and   type = 'U')
   drop table P_CategoryPriceTypes
go

if exists (select 1
            from  sysobjects
           where  id = object_id('P_ComGroup')
            and   type = 'U')
   drop table P_ComGroup
go

if exists (select 1
            from  sysobjects
           where  id = object_id('P_CompanyBrands')
            and   type = 'U')
   drop table P_CompanyBrands
go

if exists (select 1
            from  sysobjects
           where  id = object_id('P_CustomCategory')
            and   type = 'U')
   drop table P_CustomCategory
go

if exists (select 1
            from  sysobjects
           where  id = object_id('P_ManagerFavorite')
            and   type = 'U')
   drop table P_ManagerFavorite
go

if exists (select 1
            from  sysobjects
           where  id = object_id('P_ManagerFavoriteDir')
            and   type = 'U')
   drop table P_ManagerFavoriteDir
go

if exists (select 1
            from  sysobjects
           where  id = object_id('P_News')
            and   type = 'U')
   drop table P_News
go

if exists (select 1
            from  sysobjects
           where  id = object_id('P_OptionsLog')
            and   type = 'U')
   drop table P_OptionsLog
go

if exists (select 1
            from  sysobjects
           where  id = object_id('P_OtherBrands')
            and   type = 'U')
   drop table P_OtherBrands
go

if exists (select 1
            from  sysobjects
           where  id = object_id('P_PMSed')
            and   type = 'U')
   drop table P_PMSed
go

if exists (select 1
            from  sysobjects
           where  id = object_id('P_PriceAreaPermission')
            and   type = 'U')
   drop table P_PriceAreaPermission
go

if exists (select 1
            from  sysobjects
           where  id = object_id('P_PriceHistory')
            and   type = 'U')
   drop table P_PriceHistory
go

if exists (select 1
            from  sysobjects
           where  id = object_id('P_PriceOneselfPermission')
            and   type = 'U')
   drop table P_PriceOneselfPermission
go

if exists (select 1
            from  sysobjects
           where  id = object_id('P_PriceTypeAreaPermission')
            and   type = 'U')
   drop table P_PriceTypeAreaPermission
go

if exists (select 1
            from  sysobjects
           where  id = object_id('P_PriceTypeOneselfPermission')
            and   type = 'U')
   drop table P_PriceTypeOneselfPermission
go

if exists (select 1
            from  sysobjects
           where  id = object_id('P_PriceViewHistory')
            and   type = 'U')
   drop table P_PriceViewHistory
go

if exists (select 1
            from  sysobjects
           where  id = object_id('P_ProductArea')
            and   type = 'U')
   drop table P_ProductArea
go

if exists (select 1
            from  sysobjects
           where  id = object_id('P_ProductFolders')
            and   type = 'U')
   drop table P_ProductFolders
go

if exists (select 1
            from  sysobjects
           where  id = object_id('P_ProductPrices')
            and   type = 'U')
   drop table P_ProductPrices
go

if exists (select 1
            from  sysobjects
           where  id = object_id('P_Products')
            and   type = 'U')
   drop table P_Products
go

if exists (select 1
            from  sysobjects
           where  id = object_id('P_SearchFilter')
            and   type = 'U')
   drop table P_SearchFilter
go

if exists (select 1
            from  sysobjects
           where  id = object_id('P_SysBrandLibrary')
            and   type = 'U')
   drop table P_SysBrandLibrary
go

if exists (select 1
            from  sysobjects
           where  id = object_id('P_SysBrandRelationship')
            and   type = 'U')
   drop table P_SysBrandRelationship
go

if exists (select 1
            from  sysobjects
           where  id = object_id('P_SysCustomParamTemplete')
            and   type = 'U')
   drop table P_SysCustomParamTemplete
go

if exists (select 1
            from  sysobjects
           where  id = object_id('P_SysProductCategory')
            and   type = 'U')
   drop table P_SysProductCategory
go

if exists (select 1
            from  sysobjects
           where  id = object_id('PriceUpdatingSubscription')
            and   type = 'U')
   drop table PriceUpdatingSubscription
go

if exists (select 1
            from  sysobjects
           where  id = object_id('SystemSetting')
            and   type = 'U')
   drop table SystemSetting
go

if exists (select 1
            from  sysobjects
           where  id = object_id('m_Banks')
            and   type = 'U')
   drop table m_Banks
go

if exists (select 1
            from  sysobjects
           where  id = object_id('m_CompanyPrice')
            and   type = 'U')
   drop table m_CompanyPrice
go

if exists (select 1
            from  sysobjects
           where  id = object_id('m_InviteCode')
            and   type = 'U')
   drop table m_InviteCode
go

if exists (select 1
            from  sysobjects
           where  id = object_id('m_roles')
            and   type = 'U')
   drop table m_roles
go

if exists (select 1
            from  sysobjects
           where  id = object_id('m_userext')
            and   type = 'U')
   drop table m_userext
go

if exists (select 1
            from  sysobjects
           where  id = object_id('sys_lastUpdates')
            and   type = 'U')
   drop table sys_lastUpdates
go

if exists (select 1
            from  sysobjects
           where  id = object_id('sys_lastupdatekeys')
            and   type = 'U')
   drop table sys_lastupdatekeys
go

/*==============================================================*/
/* Table: AdNewsGroup                                           */
/*==============================================================*/
create table AdNewsGroup (
   groupid              int                  identity,
   shopId               int                  null,
   groupName            nvarchar(255)        null,
   constraint PK_ADNEWSGROUP primary key nonclustered (groupid)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '渠道新闻分组',
   'user', @CurrentUser, 'table', 'AdNewsGroup'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '分组编号',
   'user', @CurrentUser, 'table', 'AdNewsGroup', 'column', 'groupid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '公司编号',
   'user', @CurrentUser, 'table', 'AdNewsGroup', 'column', 'shopId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '分组名称',
   'user', @CurrentUser, 'table', 'AdNewsGroup', 'column', 'groupName'
go

/*==============================================================*/
/* Table: CategoryRelQuote                                      */
/*==============================================================*/
create table CategoryRelQuote (
   uid                  int                  null,
   folderid             int                  null,
   owneruid             int                  null,
   brid                 int                  null
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '品类引用',
   'user', @CurrentUser, 'table', 'CategoryRelQuote'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '用户编号',
   'user', @CurrentUser, 'table', 'CategoryRelQuote', 'column', 'uid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '被引用文件夹',
   'user', @CurrentUser, 'table', 'CategoryRelQuote', 'column', 'folderid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '被引用用户编号',
   'user', @CurrentUser, 'table', 'CategoryRelQuote', 'column', 'owneruid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '品类编号',
   'user', @CurrentUser, 'table', 'CategoryRelQuote', 'column', 'brid'
go

/*==============================================================*/
/* Table: ComBlackList                                          */
/*==============================================================*/
create table ComBlackList (
   comid                int                  null,
   bComid               int                  null
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '企业黑名单',
   'user', @CurrentUser, 'table', 'ComBlackList'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '公司编号',
   'user', @CurrentUser, 'table', 'ComBlackList', 'column', 'comid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '黑名单公司编号',
   'user', @CurrentUser, 'table', 'ComBlackList', 'column', 'bComid'
go

/*==============================================================*/
/* Table: EntFirend                                             */
/*==============================================================*/
create table EntFirend (
   groupid              int                  null,
   uid                  int                  null,
   comid                int                  null
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '企业好友',
   'user', @CurrentUser, 'table', 'EntFirend'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '企业分组编号',
   'user', @CurrentUser, 'table', 'EntFirend', 'column', 'groupid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '用户编号',
   'user', @CurrentUser, 'table', 'EntFirend', 'column', 'uid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '企业编号',
   'user', @CurrentUser, 'table', 'EntFirend', 'column', 'comid'
go

/*==============================================================*/
/* Table: EntFriendGroup                                        */
/*==============================================================*/
create table EntFriendGroup (
   groupid              int                  identity,
   uid                  int                  null,
   groupname            nvarchar(255)        null,
   constraint PK_ENTFRIENDGROUP primary key nonclustered (groupid)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '企业好友分组',
   'user', @CurrentUser, 'table', 'EntFriendGroup'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '分组编号',
   'user', @CurrentUser, 'table', 'EntFriendGroup', 'column', 'groupid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '用户编号',
   'user', @CurrentUser, 'table', 'EntFriendGroup', 'column', 'uid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '分组名称',
   'user', @CurrentUser, 'table', 'EntFriendGroup', 'column', 'groupname'
go

/*==============================================================*/
/* Table: FriendChatMemo                                        */
/*==============================================================*/
create table FriendChatMemo (
   fcmId                int                  identity,
   uid                  int                  null,
   friendid             int                  null,
   content              nvarchar(255)        null,
   constraint PK_FRIENDCHATMEMO primary key nonclustered (fcmId)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '好友聊天备注',
   'user', @CurrentUser, 'table', 'FriendChatMemo'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '编号',
   'user', @CurrentUser, 'table', 'FriendChatMemo', 'column', 'fcmId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '用户编号',
   'user', @CurrentUser, 'table', 'FriendChatMemo', 'column', 'uid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '好友编号',
   'user', @CurrentUser, 'table', 'FriendChatMemo', 'column', 'friendid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '内容',
   'user', @CurrentUser, 'table', 'FriendChatMemo', 'column', 'content'
go

/*==============================================================*/
/* Table: OutsideSeat                                           */
/*==============================================================*/
create table OutsideSeat (
   osid                 int                  identity,
   osname               nvarchar(255)        null,
   timeoutDate          datetime             null,
   comid                int                  null,
   uid                  int                  null,
   constraint PK_OUTSIDESEAT primary key nonclustered (osid)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '对外席位',
   'user', @CurrentUser, 'table', 'OutsideSeat'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '席位编号',
   'user', @CurrentUser, 'table', 'OutsideSeat', 'column', 'osid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '席位名称',
   'user', @CurrentUser, 'table', 'OutsideSeat', 'column', 'osname'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '到期时间',
   'user', @CurrentUser, 'table', 'OutsideSeat', 'column', 'timeoutDate'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '公司编号',
   'user', @CurrentUser, 'table', 'OutsideSeat', 'column', 'comid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '个人编号',
   'user', @CurrentUser, 'table', 'OutsideSeat', 'column', 'uid'
go

/*==============================================================*/
/* Table: P_AreaRestrict                                        */
/*==============================================================*/
create table P_AreaRestrict (
   arId                 bigint               identity,
   uid                  int                  null,
   areaId               bigint               null,
   constraint PK_P_AREARESTRICT primary key nonclustered (arId)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '报价区域授权约束',
   'user', @CurrentUser, 'table', 'P_AreaRestrict'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '约束编号',
   'user', @CurrentUser, 'table', 'P_AreaRestrict', 'column', 'arId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '用户编号',
   'user', @CurrentUser, 'table', 'P_AreaRestrict', 'column', 'uid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '允许授权区域编号',
   'user', @CurrentUser, 'table', 'P_AreaRestrict', 'column', 'areaId'
go

/*==============================================================*/
/* Table: P_BrandResponsible                                    */
/*==============================================================*/
create table P_BrandResponsible (
   pbrId                int                  identity,
   shopid               int                  null,
   uid                  int                  null,
   brid                 int                  null,
   area                 nvarchar(10)         null,
   isenabled            bit                  null,
   constraint PK_P_BRANDRESPONSIBLE primary key nonclustered (pbrId)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '负责区域',
   'user', @CurrentUser, 'table', 'P_BrandResponsible'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '负责编号',
   'user', @CurrentUser, 'table', 'P_BrandResponsible', 'column', 'pbrId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '公司编号',
   'user', @CurrentUser, 'table', 'P_BrandResponsible', 'column', 'shopid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '用户编号',
   'user', @CurrentUser, 'table', 'P_BrandResponsible', 'column', 'uid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '负责品牌关联',
   'user', @CurrentUser, 'table', 'P_BrandResponsible', 'column', 'brid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '负责地区',
   'user', @CurrentUser, 'table', 'P_BrandResponsible', 'column', 'area'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '有效性',
   'user', @CurrentUser, 'table', 'P_BrandResponsible', 'column', 'isenabled'
go

/*==============================================================*/
/* Table: P_CategoryPriceTypes                                  */
/*==============================================================*/
create table P_CategoryPriceTypes (
   priceCateId          bigint               identity,
   priceCateName        nvarchar(255)        null,
   uid                  int                  null,
   brid                 bigint               null,
   constraint PK_P_CATEGORYPRICETYPES primary key nonclustered (priceCateId)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '产品类价格类别',
   'user', @CurrentUser, 'table', 'P_CategoryPriceTypes'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '价格类别编号',
   'user', @CurrentUser, 'table', 'P_CategoryPriceTypes', 'column', 'priceCateId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '价格类别名称',
   'user', @CurrentUser, 'table', 'P_CategoryPriceTypes', 'column', 'priceCateName'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '用户编号',
   'user', @CurrentUser, 'table', 'P_CategoryPriceTypes', 'column', 'uid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '品牌类别关联编号',
   'user', @CurrentUser, 'table', 'P_CategoryPriceTypes', 'column', 'brid'
go

/*==============================================================*/
/* Table: P_ComGroup                                            */
/*==============================================================*/
create table P_ComGroup (
   cgid                 int                  identity,
   comid                int                  null,
   cgName               nvarchar(255)        null,
   city                 nvarchar(10)         null,
   description          nvarchar(255)        null,
   updateTime           datetime             null,
   isenabled            bit                  null,
   bid                  nvarchar(20)         null,
   owner                nvarchar(20)         null,
   licence              nvarchar(255)        null,
   tel                  nvarchar(20)         null,
   fax                  nvarchar(20)         null,
   email                nvarchar(255)        null,
   address              nvarchar(255)        null,
   subjectioncity       nvarchar(10)         null,
   constraint PK_P_COMGROUP primary key nonclustered (cgid)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '分公司',
   'user', @CurrentUser, 'table', 'P_ComGroup'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '编号',
   'user', @CurrentUser, 'table', 'P_ComGroup', 'column', 'cgid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '公司编号',
   'user', @CurrentUser, 'table', 'P_ComGroup', 'column', 'comid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '名称',
   'user', @CurrentUser, 'table', 'P_ComGroup', 'column', 'cgName'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '所在地区',
   'user', @CurrentUser, 'table', 'P_ComGroup', 'column', 'city'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '描述',
   'user', @CurrentUser, 'table', 'P_ComGroup', 'column', 'description'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '更新日期',
   'user', @CurrentUser, 'table', 'P_ComGroup', 'column', 'updateTime'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '审核状态',
   'user', @CurrentUser, 'table', 'P_ComGroup', 'column', 'isenabled'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '工商号',
   'user', @CurrentUser, 'table', 'P_ComGroup', 'column', 'bid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '负责人',
   'user', @CurrentUser, 'table', 'P_ComGroup', 'column', 'owner'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '营业执照',
   'user', @CurrentUser, 'table', 'P_ComGroup', 'column', 'licence'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '联系电话',
   'user', @CurrentUser, 'table', 'P_ComGroup', 'column', 'tel'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '传真',
   'user', @CurrentUser, 'table', 'P_ComGroup', 'column', 'fax'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '电子邮件',
   'user', @CurrentUser, 'table', 'P_ComGroup', 'column', 'email'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '详细地址',
   'user', @CurrentUser, 'table', 'P_ComGroup', 'column', 'address'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '隶属级别地区',
   'user', @CurrentUser, 'table', 'P_ComGroup', 'column', 'subjectioncity'
go

/*==============================================================*/
/* Table: P_CompanyBrands                                       */
/*==============================================================*/
create table P_CompanyBrands (
   cbId                 int                  identity,
   ShopId               int                  null,
   brid                 int                  null,
   cateid1              int                  null,
   cateid2              int                  null,
   brandid              int                  null,
   constraint PK_P_COMPANYBRANDS primary key nonclustered (cbId)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '公司主营品牌',
   'user', @CurrentUser, 'table', 'P_CompanyBrands'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '主营品牌编号',
   'user', @CurrentUser, 'table', 'P_CompanyBrands', 'column', 'cbId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '公司编号',
   'user', @CurrentUser, 'table', 'P_CompanyBrands', 'column', 'ShopId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '关联编号',
   'user', @CurrentUser, 'table', 'P_CompanyBrands', 'column', 'brid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '类别1',
   'user', @CurrentUser, 'table', 'P_CompanyBrands', 'column', 'cateid1'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '类别2',
   'user', @CurrentUser, 'table', 'P_CompanyBrands', 'column', 'cateid2'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '品牌ID',
   'user', @CurrentUser, 'table', 'P_CompanyBrands', 'column', 'brandid'
go

/*==============================================================*/
/* Table: P_CustomCategory                                      */
/*==============================================================*/
create table P_CustomCategory (
   customCateID         bigint               identity,
   cateName             nvarchar(255)        null,
   brid                 bigint               null,
   uid                  int                  null,
   constraint PK_P_CUSTOMCATEGORY primary key nonclustered (customCateID)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '自定义产品类别',
   'user', @CurrentUser, 'table', 'P_CustomCategory'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '自定义类别编号',
   'user', @CurrentUser, 'table', 'P_CustomCategory', 'column', 'customCateID'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '类别名称',
   'user', @CurrentUser, 'table', 'P_CustomCategory', 'column', 'cateName'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '品牌类别关联编号',
   'user', @CurrentUser, 'table', 'P_CustomCategory', 'column', 'brid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '用户编号',
   'user', @CurrentUser, 'table', 'P_CustomCategory', 'column', 'uid'
go

/*==============================================================*/
/* Table: P_ManagerFavorite                                     */
/*==============================================================*/
create table P_ManagerFavorite (
   favoriteId           bigint               identity,
   dirId                bigint               null,
   uid                  bigint               null,
   managerId            bigint               null,
   dispName             nvarchar(255)        null,
   brid                 bigint               null,
   areaId               bigint               null,
   constraint PK_P_MANAGERFAVORITE primary key nonclustered (favoriteId)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '产品经理收藏',
   'user', @CurrentUser, 'table', 'P_ManagerFavorite'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '收藏编号',
   'user', @CurrentUser, 'table', 'P_ManagerFavorite', 'column', 'favoriteId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '收藏夹编号',
   'user', @CurrentUser, 'table', 'P_ManagerFavorite', 'column', 'dirId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '用户编号',
   'user', @CurrentUser, 'table', 'P_ManagerFavorite', 'column', 'uid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '产品经理编号',
   'user', @CurrentUser, 'table', 'P_ManagerFavorite', 'column', 'managerId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '显示为',
   'user', @CurrentUser, 'table', 'P_ManagerFavorite', 'column', 'dispName'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '品牌类别关联编号',
   'user', @CurrentUser, 'table', 'P_ManagerFavorite', 'column', 'brid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '区域编号',
   'user', @CurrentUser, 'table', 'P_ManagerFavorite', 'column', 'areaId'
go

/*==============================================================*/
/* Table: P_ManagerFavoriteDir                                  */
/*==============================================================*/
create table P_ManagerFavoriteDir (
   dirId                bigint               identity,
   uid                  int                  null,
   dirName              nvarchar(255)        null,
   pDirId               bigint               null,
   constraint PK_P_MANAGERFAVORITEDIR primary key nonclustered (dirId)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '产品经理收藏夹',
   'user', @CurrentUser, 'table', 'P_ManagerFavoriteDir'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '收藏夹编号',
   'user', @CurrentUser, 'table', 'P_ManagerFavoriteDir', 'column', 'dirId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '用户编号',
   'user', @CurrentUser, 'table', 'P_ManagerFavoriteDir', 'column', 'uid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '收藏夹名称',
   'user', @CurrentUser, 'table', 'P_ManagerFavoriteDir', 'column', 'dirName'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '父级收藏夹编号',
   'user', @CurrentUser, 'table', 'P_ManagerFavoriteDir', 'column', 'pDirId'
go

/*==============================================================*/
/* Table: P_News                                                */
/*==============================================================*/
create table P_News (
   pNewsId              int                  identity,
   shopid               int                  null,
   groupid              int                  null,
   groupName            nvarchar(255)        null,
   posterUid            int                  null,
   cates                text                 null,
   brandids             text                 null,
   brids                text                 null,
   selUids              text                 null,
   citys                text                 null,
   industrys            text                 null,
   title                nvarchar(255)        null,
   content              nvarchar(1000)       null,
   contentText          nvarchar(1000)       null,
   isMsg                bit                  null,
   updateTime           datetime             null,
   sentTime             datetime             null,
   isSent               bit                  null,
   uids                 text                 null,
   imgs                 text                 null,
   readCount            int                  null,
   constraint PK_P_NEWS primary key nonclustered (pNewsId)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '渠道新闻',
   'user', @CurrentUser, 'table', 'P_News'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '新闻编号',
   'user', @CurrentUser, 'table', 'P_News', 'column', 'pNewsId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '公司编号',
   'user', @CurrentUser, 'table', 'P_News', 'column', 'shopid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '分组编号',
   'user', @CurrentUser, 'table', 'P_News', 'column', 'groupid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '分组名称',
   'user', @CurrentUser, 'table', 'P_News', 'column', 'groupName'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '发布人',
   'user', @CurrentUser, 'table', 'P_News', 'column', 'posterUid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '类别编号集',
   'user', @CurrentUser, 'table', 'P_News', 'column', 'cates'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '品牌编号集',
   'user', @CurrentUser, 'table', 'P_News', 'column', 'brandids'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '品牌关联编号集合集',
   'user', @CurrentUser, 'table', 'P_News', 'column', 'brids'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '指定用户集合',
   'user', @CurrentUser, 'table', 'P_News', 'column', 'selUids'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '城市集合',
   'user', @CurrentUser, 'table', 'P_News', 'column', 'citys'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '行业集合',
   'user', @CurrentUser, 'table', 'P_News', 'column', 'industrys'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '新闻标题',
   'user', @CurrentUser, 'table', 'P_News', 'column', 'title'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '新闻内容',
   'user', @CurrentUser, 'table', 'P_News', 'column', 'content'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '新闻内容文本',
   'user', @CurrentUser, 'table', 'P_News', 'column', 'contentText'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '是否即时信息',
   'user', @CurrentUser, 'table', 'P_News', 'column', 'isMsg'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '更新时间',
   'user', @CurrentUser, 'table', 'P_News', 'column', 'updateTime'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '定时发送时间',
   'user', @CurrentUser, 'table', 'P_News', 'column', 'sentTime'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '是否已发送',
   'user', @CurrentUser, 'table', 'P_News', 'column', 'isSent'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '目标用户集合',
   'user', @CurrentUser, 'table', 'P_News', 'column', 'uids'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '图象名称集合',
   'user', @CurrentUser, 'table', 'P_News', 'column', 'imgs'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '阅读次数',
   'user', @CurrentUser, 'table', 'P_News', 'column', 'readCount'
go

/*==============================================================*/
/* Table: P_OptionsLog                                          */
/*==============================================================*/
create table P_OptionsLog (
   logId                bigint               identity,
   moduleId             nvarchar(100)        null,
   optDate              datetime             null,
   ComId                int                  null,
   Uid                  int                  null,
   descr                nvarchar(255)        null,
   constraint PK_P_OPTIONSLOG primary key nonclustered (logId)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '操作日志',
   'user', @CurrentUser, 'table', 'P_OptionsLog'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '日志编号',
   'user', @CurrentUser, 'table', 'P_OptionsLog', 'column', 'logId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '模块编号',
   'user', @CurrentUser, 'table', 'P_OptionsLog', 'column', 'moduleId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '操作日期',
   'user', @CurrentUser, 'table', 'P_OptionsLog', 'column', 'optDate'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '公司编号',
   'user', @CurrentUser, 'table', 'P_OptionsLog', 'column', 'ComId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '操作员',
   'user', @CurrentUser, 'table', 'P_OptionsLog', 'column', 'Uid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '动作',
   'user', @CurrentUser, 'table', 'P_OptionsLog', 'column', 'descr'
go

/*==============================================================*/
/* Table: P_OtherBrands                                         */
/*==============================================================*/
create table P_OtherBrands (
   obrid                int                  identity,
   comid                int                  not null,
   cateid1              int                  null,
   cateid2              int                  null,
   brandName            nvarchar(255)        null,
   constraint PK_P_OTHERBRANDS primary key nonclustered (obrid)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '其他品牌表',
   'user', @CurrentUser, 'table', 'P_OtherBrands'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '其他品牌关联表',
   'user', @CurrentUser, 'table', 'P_OtherBrands', 'column', 'obrid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '用户编号',
   'user', @CurrentUser, 'table', 'P_OtherBrands', 'column', 'comid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '类别1',
   'user', @CurrentUser, 'table', 'P_OtherBrands', 'column', 'cateid1'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '类别2',
   'user', @CurrentUser, 'table', 'P_OtherBrands', 'column', 'cateid2'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '名牌名称',
   'user', @CurrentUser, 'table', 'P_OtherBrands', 'column', 'brandName'
go

/*==============================================================*/
/* Table: P_PMSed                                               */
/*==============================================================*/
create table P_PMSed (
   pmsuid               int                  null,
   brid                 int                  null,
   uid                  int                  null
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '授权过',
   'user', @CurrentUser, 'table', 'P_PMSed'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '被授权用户编号',
   'user', @CurrentUser, 'table', 'P_PMSed', 'column', 'pmsuid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '品类编号',
   'user', @CurrentUser, 'table', 'P_PMSed', 'column', 'brid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '产品所有人编号',
   'user', @CurrentUser, 'table', 'P_PMSed', 'column', 'uid'
go

/*==============================================================*/
/* Table: P_PriceAreaPermission                                 */
/*==============================================================*/
create table P_PriceAreaPermission (
   areaPmsId            bigint               identity,
   uid                  int                  null,
   productId            bigint               null,
   productPriceId       bigint               null,
   areaId               bigint               null,
   constraint PK_P_PRICEAREAPERMISSION primary key nonclustered (areaPmsId)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '报价区域授权',
   'user', @CurrentUser, 'table', 'P_PriceAreaPermission'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '区域授权编号',
   'user', @CurrentUser, 'table', 'P_PriceAreaPermission', 'column', 'areaPmsId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '用户编号',
   'user', @CurrentUser, 'table', 'P_PriceAreaPermission', 'column', 'uid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '产品编号',
   'user', @CurrentUser, 'table', 'P_PriceAreaPermission', 'column', 'productId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '产品价格编号',
   'user', @CurrentUser, 'table', 'P_PriceAreaPermission', 'column', 'productPriceId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '授权区域编号',
   'user', @CurrentUser, 'table', 'P_PriceAreaPermission', 'column', 'areaId'
go

/*==============================================================*/
/* Table: P_PriceHistory                                        */
/*==============================================================*/
create table P_PriceHistory (
   priceHisId           bigint               identity,
   productId            bigint               null,
   priceCateId          bigint               null,
   prices               float                null,
   curDate              datetime             null,
   constraint PK_P_PRICEHISTORY primary key nonclustered (priceHisId)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '产品历史报价',
   'user', @CurrentUser, 'table', 'P_PriceHistory'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '历史报价编号',
   'user', @CurrentUser, 'table', 'P_PriceHistory', 'column', 'priceHisId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '产品编号',
   'user', @CurrentUser, 'table', 'P_PriceHistory', 'column', 'productId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '价格类别编号',
   'user', @CurrentUser, 'table', 'P_PriceHistory', 'column', 'priceCateId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '当期价格',
   'user', @CurrentUser, 'table', 'P_PriceHistory', 'column', 'prices'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '报价日期',
   'user', @CurrentUser, 'table', 'P_PriceHistory', 'column', 'curDate'
go

/*==============================================================*/
/* Table: P_PriceOneselfPermission                              */
/*==============================================================*/
create table P_PriceOneselfPermission (
   oneselfPmsId         bigint               identity,
   uid                  int                  null,
   productId            bigint               null,
   productPriceId       bigint               null,
   pmsUid               bigint               null,
   constraint PK_P_PRICEONESELFPERMISSION primary key nonclustered (oneselfPmsId)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '报价单独授权',
   'user', @CurrentUser, 'table', 'P_PriceOneselfPermission'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '单独授权编号',
   'user', @CurrentUser, 'table', 'P_PriceOneselfPermission', 'column', 'oneselfPmsId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '用户编号',
   'user', @CurrentUser, 'table', 'P_PriceOneselfPermission', 'column', 'uid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '产品编号',
   'user', @CurrentUser, 'table', 'P_PriceOneselfPermission', 'column', 'productId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '产品价格编号',
   'user', @CurrentUser, 'table', 'P_PriceOneselfPermission', 'column', 'productPriceId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '授权用户编号',
   'user', @CurrentUser, 'table', 'P_PriceOneselfPermission', 'column', 'pmsUid'
go

/*==============================================================*/
/* Table: P_PriceTypeAreaPermission                             */
/*==============================================================*/
create table P_PriceTypeAreaPermission (
   ptapId               bigint               identity,
   uid                  int                  null,
   priceCateId          bigint               null,
   areaId               bigint               null,
   constraint PK_P_PRICETYPEAREAPERMISSION primary key nonclustered (ptapId)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '报价类别区域授权',
   'user', @CurrentUser, 'table', 'P_PriceTypeAreaPermission'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '类别区域授权编号',
   'user', @CurrentUser, 'table', 'P_PriceTypeAreaPermission', 'column', 'ptapId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '用户编号',
   'user', @CurrentUser, 'table', 'P_PriceTypeAreaPermission', 'column', 'uid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '价格类别编号',
   'user', @CurrentUser, 'table', 'P_PriceTypeAreaPermission', 'column', 'priceCateId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '授权区域编号',
   'user', @CurrentUser, 'table', 'P_PriceTypeAreaPermission', 'column', 'areaId'
go

/*==============================================================*/
/* Table: P_PriceTypeOneselfPermission                          */
/*==============================================================*/
create table P_PriceTypeOneselfPermission (
   ptopId               bigint               identity,
   uid                  int                  null,
   priceCateId          bigint               null,
   pmsUid               bigint               null,
   timeoutDate          datetime             null,
   constraint PK_P_PRICETYPEONESELFPERMISSIO primary key nonclustered (ptopId)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '报价类别单独授权',
   'user', @CurrentUser, 'table', 'P_PriceTypeOneselfPermission'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '类别单独授权编号',
   'user', @CurrentUser, 'table', 'P_PriceTypeOneselfPermission', 'column', 'ptopId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '用户编号',
   'user', @CurrentUser, 'table', 'P_PriceTypeOneselfPermission', 'column', 'uid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '价格类别编号',
   'user', @CurrentUser, 'table', 'P_PriceTypeOneselfPermission', 'column', 'priceCateId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '授权用户编号',
   'user', @CurrentUser, 'table', 'P_PriceTypeOneselfPermission', 'column', 'pmsUid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '截止日期',
   'user', @CurrentUser, 'table', 'P_PriceTypeOneselfPermission', 'column', 'timeoutDate'
go

/*==============================================================*/
/* Table: P_PriceViewHistory                                    */
/*==============================================================*/
create table P_PriceViewHistory (
   viewHisId            bigint               identity,
   productId            bigint               null,
   priceCateId          bigint               null,
   uid                  int                  null,
   prices               float                null,
   curDate              datetime             null,
   constraint PK_P_PRICEVIEWHISTORY primary key nonclustered (viewHisId)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '报价查看历史',
   'user', @CurrentUser, 'table', 'P_PriceViewHistory'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '查看历史编号',
   'user', @CurrentUser, 'table', 'P_PriceViewHistory', 'column', 'viewHisId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '产品编号',
   'user', @CurrentUser, 'table', 'P_PriceViewHistory', 'column', 'productId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '价格类别编号',
   'user', @CurrentUser, 'table', 'P_PriceViewHistory', 'column', 'priceCateId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '查看者用户编号',
   'user', @CurrentUser, 'table', 'P_PriceViewHistory', 'column', 'uid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '当期价格',
   'user', @CurrentUser, 'table', 'P_PriceViewHistory', 'column', 'prices'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '查看日期',
   'user', @CurrentUser, 'table', 'P_PriceViewHistory', 'column', 'curDate'
go

/*==============================================================*/
/* Table: P_ProductArea                                         */
/*==============================================================*/
create table P_ProductArea (
   areaId               bigint               identity,
   areaName             nvarchar(255)        null,
   pAreaId              bigint               null,
   constraint PK_P_PRODUCTAREA primary key nonclustered (areaId)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '产品区域',
   'user', @CurrentUser, 'table', 'P_ProductArea'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '区域编号',
   'user', @CurrentUser, 'table', 'P_ProductArea', 'column', 'areaId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '区域名称',
   'user', @CurrentUser, 'table', 'P_ProductArea', 'column', 'areaName'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '父级区域编号',
   'user', @CurrentUser, 'table', 'P_ProductArea', 'column', 'pAreaId'
go

/*==============================================================*/
/* Table: P_ProductFolders                                      */
/*==============================================================*/
create table P_ProductFolders (
   folderId             bigint               identity,
   uid                  int                  null,
   folderName           nvarchar(255)        null,
   folderType           nvarchar(255)        null,
   pFolderId            bigint               null,
   brid                 bigint               null,
   lastUpdateTime       datetime             null,
   paramfields          nvarchar(1000)       null,
   shopid               int                  null,
   constraint PK_P_PRODUCTFOLDERS primary key nonclustered (folderId)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '产品文件夹',
   'user', @CurrentUser, 'table', 'P_ProductFolders'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '产品文件夹编号',
   'user', @CurrentUser, 'table', 'P_ProductFolders', 'column', 'folderId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '用户编号',
   'user', @CurrentUser, 'table', 'P_ProductFolders', 'column', 'uid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '文件夹名称',
   'user', @CurrentUser, 'table', 'P_ProductFolders', 'column', 'folderName'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '文件夹类型',
   'user', @CurrentUser, 'table', 'P_ProductFolders', 'column', 'folderType'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '父级文件夹编号',
   'user', @CurrentUser, 'table', 'P_ProductFolders', 'column', 'pFolderId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '品牌类别关联编号',
   'user', @CurrentUser, 'table', 'P_ProductFolders', 'column', 'brid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '最后更新时间',
   'user', @CurrentUser, 'table', 'P_ProductFolders', 'column', 'lastUpdateTime'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '参数字段',
   'user', @CurrentUser, 'table', 'P_ProductFolders', 'column', 'paramfields'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '公司编号',
   'user', @CurrentUser, 'table', 'P_ProductFolders', 'column', 'shopid'
go

/*==============================================================*/
/* Table: P_ProductPrices                                       */
/*==============================================================*/
create table P_ProductPrices (
   productPriceId       bigint               identity,
   uid                  int                  null,
   productId            bigint               null,
   priceCateId          bigint               null,
   prices               float                null,
   constraint PK_P_PRODUCTPRICES primary key nonclustered (productPriceId)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '产品价格',
   'user', @CurrentUser, 'table', 'P_ProductPrices'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '产品价格编号',
   'user', @CurrentUser, 'table', 'P_ProductPrices', 'column', 'productPriceId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '用户编号',
   'user', @CurrentUser, 'table', 'P_ProductPrices', 'column', 'uid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '产品编号',
   'user', @CurrentUser, 'table', 'P_ProductPrices', 'column', 'productId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '价格类别编号',
   'user', @CurrentUser, 'table', 'P_ProductPrices', 'column', 'priceCateId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '价格',
   'user', @CurrentUser, 'table', 'P_ProductPrices', 'column', 'prices'
go

/*==============================================================*/
/* Table: P_Products                                            */
/*==============================================================*/
create table P_Products (
   productId            bigint               identity,
   uid                  int                  null,
   cateid1              bigint               null,
   cateid2              bigint               null,
   brandId              bigint               null,
   brid                 bigint               null,
   customCateID         bigint               null,
   productName          nvarchar(255)        null,
   productDesc          nvarchar(1000)       null,
   IsNew                bit                  null,
   IsWant               bit                  null,
   IsHot                bit                  null,
   storeStatus          nvarchar(20)         null,
   picName              nvarchar(255)        null,
   detailsArgs          nvarchar(255)        null,
   updateTime           datetime             null,
   otherBrandName       nvarchar(20)         null,
   IsDisp               bit                  null,
   unit                 nvarchar(5)          null,
   params               nvarchar(1500)       null,
   constraint PK_P_PRODUCTS primary key nonclustered (productId)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '产品资料',
   'user', @CurrentUser, 'table', 'P_Products'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '产品编号',
   'user', @CurrentUser, 'table', 'P_Products', 'column', 'productId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '用户编号',
   'user', @CurrentUser, 'table', 'P_Products', 'column', 'uid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '产品类别1',
   'user', @CurrentUser, 'table', 'P_Products', 'column', 'cateid1'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '产品类别2',
   'user', @CurrentUser, 'table', 'P_Products', 'column', 'cateid2'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '品牌编号',
   'user', @CurrentUser, 'table', 'P_Products', 'column', 'brandId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '品牌类别关联编号',
   'user', @CurrentUser, 'table', 'P_Products', 'column', 'brid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '自定义类别编号',
   'user', @CurrentUser, 'table', 'P_Products', 'column', 'customCateID'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '产品型号',
   'user', @CurrentUser, 'table', 'P_Products', 'column', 'productName'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '产品简介',
   'user', @CurrentUser, 'table', 'P_Products', 'column', 'productDesc'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '新品',
   'user', @CurrentUser, 'table', 'P_Products', 'column', 'IsNew'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '缺货',
   'user', @CurrentUser, 'table', 'P_Products', 'column', 'IsWant'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '热卖',
   'user', @CurrentUser, 'table', 'P_Products', 'column', 'IsHot'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '库存状态',
   'user', @CurrentUser, 'table', 'P_Products', 'column', 'storeStatus'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '图片名',
   'user', @CurrentUser, 'table', 'P_Products', 'column', 'picName'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '详细介绍',
   'user', @CurrentUser, 'table', 'P_Products', 'column', 'detailsArgs'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '更新日期',
   'user', @CurrentUser, 'table', 'P_Products', 'column', 'updateTime'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '其他品牌备注',
   'user', @CurrentUser, 'table', 'P_Products', 'column', 'otherBrandName'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '是否显示',
   'user', @CurrentUser, 'table', 'P_Products', 'column', 'IsDisp'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '单位',
   'user', @CurrentUser, 'table', 'P_Products', 'column', 'unit'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '参数信息',
   'user', @CurrentUser, 'table', 'P_Products', 'column', 'params'
go

/*==============================================================*/
/* Table: P_SearchFilter                                        */
/*==============================================================*/
create table P_SearchFilter (
   comid                int                  null,
   brid                 int                  null,
   areas                nvarchar(1000)       null
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '品牌搜索约束',
   'user', @CurrentUser, 'table', 'P_SearchFilter'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '公司编号',
   'user', @CurrentUser, 'table', 'P_SearchFilter', 'column', 'comid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '关联编号',
   'user', @CurrentUser, 'table', 'P_SearchFilter', 'column', 'brid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '地区集合',
   'user', @CurrentUser, 'table', 'P_SearchFilter', 'column', 'areas'
go

/*==============================================================*/
/* Table: P_SysBrandLibrary                                     */
/*==============================================================*/
create table P_SysBrandLibrary (
   brandId              bigint               identity,
   brandName            nvarchar(255)        null,
   firstPinyin          nvarchar(1)          null,
   english              nvarchar(255)        null,
   sortBy               int                  null,
   constraint PK_P_SYSBRANDLIBRARY primary key nonclustered (brandId)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '产品品牌库',
   'user', @CurrentUser, 'table', 'P_SysBrandLibrary'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '品牌库编号',
   'user', @CurrentUser, 'table', 'P_SysBrandLibrary', 'column', 'brandId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '品牌名称',
   'user', @CurrentUser, 'table', 'P_SysBrandLibrary', 'column', 'brandName'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '拼音',
   'user', @CurrentUser, 'table', 'P_SysBrandLibrary', 'column', 'firstPinyin'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '英文名',
   'user', @CurrentUser, 'table', 'P_SysBrandLibrary', 'column', 'english'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '排序',
   'user', @CurrentUser, 'table', 'P_SysBrandLibrary', 'column', 'sortBy'
go

/*==============================================================*/
/* Table: P_SysBrandRelationship                                */
/*==============================================================*/
create table P_SysBrandRelationship (
   brid                 bigint               identity,
   brandId              bigint               null,
   cateid               bigint               null,
   sortBy               int                  null,
   constraint PK_P_SYSBRANDRELATIONSHIP primary key nonclustered (brid)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '品牌类别关联表',
   'user', @CurrentUser, 'table', 'P_SysBrandRelationship'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '品牌类别关联编号',
   'user', @CurrentUser, 'table', 'P_SysBrandRelationship', 'column', 'brid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '品牌库编号',
   'user', @CurrentUser, 'table', 'P_SysBrandRelationship', 'column', 'brandId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '产品类别编号',
   'user', @CurrentUser, 'table', 'P_SysBrandRelationship', 'column', 'cateid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '排序',
   'user', @CurrentUser, 'table', 'P_SysBrandRelationship', 'column', 'sortBy'
go

/*==============================================================*/
/* Table: P_SysCustomParamTemplete                              */
/*==============================================================*/
create table P_SysCustomParamTemplete (
   cateid               int                  null,
   paramfields          nvarchar(1000)       null
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '自定义参数模板',
   'user', @CurrentUser, 'table', 'P_SysCustomParamTemplete'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '产品类别编号',
   'user', @CurrentUser, 'table', 'P_SysCustomParamTemplete', 'column', 'cateid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '配置信息',
   'user', @CurrentUser, 'table', 'P_SysCustomParamTemplete', 'column', 'paramfields'
go

/*==============================================================*/
/* Table: P_SysProductCategory                                  */
/*==============================================================*/
create table P_SysProductCategory (
   cateid               bigint               identity,
   cateName             nvarchar(255)        null,
   parentCateId         bigint               null,
   firstPinyin          nvarchar(1)          null,
   sortBy               int                  null,
   constraint PK_P_SYSPRODUCTCATEGORY primary key nonclustered (cateid)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '产品类别',
   'user', @CurrentUser, 'table', 'P_SysProductCategory'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '产品类别编号',
   'user', @CurrentUser, 'table', 'P_SysProductCategory', 'column', 'cateid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '产品类别名称',
   'user', @CurrentUser, 'table', 'P_SysProductCategory', 'column', 'cateName'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '父级编号',
   'user', @CurrentUser, 'table', 'P_SysProductCategory', 'column', 'parentCateId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '拼音',
   'user', @CurrentUser, 'table', 'P_SysProductCategory', 'column', 'firstPinyin'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '排序',
   'user', @CurrentUser, 'table', 'P_SysProductCategory', 'column', 'sortBy'
go

/*==============================================================*/
/* Table: PriceUpdatingSubscription                             */
/*==============================================================*/
create table PriceUpdatingSubscription (
   uid                  int                  null,
   objUid               int                  null,
   brid                 int                  null
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '报价更新订阅',
   'user', @CurrentUser, 'table', 'PriceUpdatingSubscription'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '订阅人用户编号',
   'user', @CurrentUser, 'table', 'PriceUpdatingSubscription', 'column', 'uid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '产品所有人用户编号',
   'user', @CurrentUser, 'table', 'PriceUpdatingSubscription', 'column', 'objUid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '品类编号',
   'user', @CurrentUser, 'table', 'PriceUpdatingSubscription', 'column', 'brid'
go

/*==============================================================*/
/* Table: SystemSetting                                         */
/*==============================================================*/
create table SystemSetting (
   GategoryUpdateTime   datetime             null
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '系统配置',
   'user', @CurrentUser, 'table', 'SystemSetting'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '类别最后更新时间',
   'user', @CurrentUser, 'table', 'SystemSetting', 'column', 'GategoryUpdateTime'
go

/*==============================================================*/
/* Table: m_Banks                                               */
/*==============================================================*/
create table m_Banks (
   bkid                 int                  identity,
   comid                int                  null,
   bktype               int                  null,
   bankid               nvarchar(20)         null,
   bankuname            nvarchar(20)         null,
   bankname             nvarchar(20)         null,
   memo                 nvarchar(50)         null,
   constraint PK_M_BANKS primary key (bkid)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '企业银行账户',
   'user', @CurrentUser, 'table', 'm_Banks'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '银行编号',
   'user', @CurrentUser, 'table', 'm_Banks', 'column', 'bkid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '企业编号',
   'user', @CurrentUser, 'table', 'm_Banks', 'column', 'comid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '账户类型',
   'user', @CurrentUser, 'table', 'm_Banks', 'column', 'bktype'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '帐号',
   'user', @CurrentUser, 'table', 'm_Banks', 'column', 'bankid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '户名',
   'user', @CurrentUser, 'table', 'm_Banks', 'column', 'bankuname'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '开户行',
   'user', @CurrentUser, 'table', 'm_Banks', 'column', 'bankname'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '帐号说明',
   'user', @CurrentUser, 'table', 'm_Banks', 'column', 'memo'
go

/*==============================================================*/
/* Table: m_CompanyPrice                                        */
/*==============================================================*/
create table m_CompanyPrice (
   cpid                 int                  identity,
   brid                 int                  null,
   uid                  int                  null,
   shopid               int                  null,
   pricecateid          int                  null,
   areaid               int                  null,
   brname               nvarchar(50)         null,
   constraint PK_M_COMPANYPRICE primary key (cpid)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '公司对外报价',
   'user', @CurrentUser, 'table', 'm_CompanyPrice'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '编号',
   'user', @CurrentUser, 'table', 'm_CompanyPrice', 'column', 'cpid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '品类编号',
   'user', @CurrentUser, 'table', 'm_CompanyPrice', 'column', 'brid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '产品专员编号',
   'user', @CurrentUser, 'table', 'm_CompanyPrice', 'column', 'uid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '公司编号',
   'user', @CurrentUser, 'table', 'm_CompanyPrice', 'column', 'shopid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '价格类型编号',
   'user', @CurrentUser, 'table', 'm_CompanyPrice', 'column', 'pricecateid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '区域编号',
   'user', @CurrentUser, 'table', 'm_CompanyPrice', 'column', 'areaid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '对外品类名称',
   'user', @CurrentUser, 'table', 'm_CompanyPrice', 'column', 'brname'
go

/*==============================================================*/
/* Table: m_InviteCode                                          */
/*==============================================================*/
create table m_InviteCode (
   icid                 int                  identity,
   mobile               nvarchar(11)         null,
   code                 nvarchar(5)          null,
   senddate             datetime             null,
   sendcomid            int                  null,
   recvcomid            int                  null,
   comname              nvarchar(20)         null,
   contact              nvarchar(5)          null,
   constraint PK_M_INVITECODE primary key (icid)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '企业邀请码',
   'user', @CurrentUser, 'table', 'm_InviteCode'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '邀请码编号',
   'user', @CurrentUser, 'table', 'm_InviteCode', 'column', 'icid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '手机号码',
   'user', @CurrentUser, 'table', 'm_InviteCode', 'column', 'mobile'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '邀请码',
   'user', @CurrentUser, 'table', 'm_InviteCode', 'column', 'code'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '发送日期',
   'user', @CurrentUser, 'table', 'm_InviteCode', 'column', 'senddate'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '发送企业',
   'user', @CurrentUser, 'table', 'm_InviteCode', 'column', 'sendcomid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '接收企业',
   'user', @CurrentUser, 'table', 'm_InviteCode', 'column', 'recvcomid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '企业名称',
   'user', @CurrentUser, 'table', 'm_InviteCode', 'column', 'comname'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '联系人',
   'user', @CurrentUser, 'table', 'm_InviteCode', 'column', 'contact'
go

/*==============================================================*/
/* Table: m_roles                                               */
/*==============================================================*/
create table m_roles (
   roleid               int                  identity,
   comid                int                  null,
   rolename             nvarchar(20)         null,
   permission           nvarchar(500)        null,
   constraint PK_M_ROLES primary key (roleid)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '角色组',
   'user', @CurrentUser, 'table', 'm_roles'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '
   ',
   'user', @CurrentUser, 'table', 'm_roles', 'column', 'roleid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '公司编号',
   'user', @CurrentUser, 'table', 'm_roles', 'column', 'comid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '角色名称',
   'user', @CurrentUser, 'table', 'm_roles', 'column', 'rolename'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '权限',
   'user', @CurrentUser, 'table', 'm_roles', 'column', 'permission'
go

/*==============================================================*/
/* Table: m_userext                                             */
/*==============================================================*/
create table m_userext (
   uexid                int                  identity,
   uid                  int                  null,
   roleid               int                  null,
   permission           nvarchar(500)        null,
   constraint PK_M_USEREXT primary key (uexid)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '用户扩展信息',
   'user', @CurrentUser, 'table', 'm_userext'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '扩展编号',
   'user', @CurrentUser, 'table', 'm_userext', 'column', 'uexid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '用户编号',
   'user', @CurrentUser, 'table', 'm_userext', 'column', 'uid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '角色编号',
   'user', @CurrentUser, 'table', 'm_userext', 'column', 'roleid'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '权限',
   'user', @CurrentUser, 'table', 'm_userext', 'column', 'permission'
go

/*==============================================================*/
/* Table: sys_lastUpdates                                       */
/*==============================================================*/
create table sys_lastUpdates (
   keyId                int                  null,
   updatetime           datetime             null
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '最后更新时间',
   'user', @CurrentUser, 'table', 'sys_lastUpdates'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '更新时间编号',
   'user', @CurrentUser, 'table', 'sys_lastUpdates', 'column', 'keyId'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '更新时间',
   'user', @CurrentUser, 'table', 'sys_lastUpdates', 'column', 'updatetime'
go

/*==============================================================*/
/* Table: sys_lastupdatekeys                                    */
/*==============================================================*/
create table sys_lastupdatekeys (
   keyID                int                  identity,
   keyName              nvarchar(50)         null,
   descr                nvarchar(30)         null,
   constraint PK_SYS_LASTUPDATEKEYS primary key (keyID)
)
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '最后更新时间键值',
   'user', @CurrentUser, 'table', 'sys_lastupdatekeys'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '关键编号',
   'user', @CurrentUser, 'table', 'sys_lastupdatekeys', 'column', 'keyID'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '关键字',
   'user', @CurrentUser, 'table', 'sys_lastupdatekeys', 'column', 'keyName'
go

declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description', 
   '描述信息',
   'user', @CurrentUser, 'table', 'sys_lastupdatekeys', 'column', 'descr'
go

alter table EntFirend
   add constraint FK_ENTFIREN_REFERENCE_ENTFRIEN foreign key (groupid)
      references EntFriendGroup (groupid)
         on update cascade on delete cascade
go

alter table P_CategoryPriceTypes
   add constraint FK_P_CATEGO_REFERENCE_P_SYSBRA foreign key (brid)
      references P_SysBrandRelationship (brid)
go

alter table P_CustomCategory
   add constraint FK_P_CUSTOM_REFERENCE_P_SYSBRA foreign key (brid)
      references P_SysBrandRelationship (brid)
go

alter table P_News
   add constraint FK_P_NEWS_REFERENCE_ADNEWSGR foreign key (groupid)
      references AdNewsGroup (groupid)
         on update cascade on delete cascade
go

alter table P_PriceAreaPermission
   add constraint FK_P_PRICEA_REFERENCE_P_PRODUC_2 foreign key (areaId)
      references P_ProductArea (areaId)
go

alter table P_PriceAreaPermission
   add constraint FK_P_PRICEA_REFERENCE_P_PRODUC foreign key (productPriceId)
      references P_ProductPrices (productPriceId)
go

alter table P_PriceHistory
   add constraint FK_P_PRICEH_REFERENCE_P_PRODUC foreign key (productId)
      references P_Products (productId)
         on update cascade on delete cascade
go

alter table P_PriceOneselfPermission
   add constraint FK_P_PRICEO_REFERENCE_P_PRODUC foreign key (productPriceId)
      references P_ProductPrices (productPriceId)
go

alter table P_PriceTypeAreaPermission
   add constraint FK_P_PRICET_REFERENCE_P_CATEGO foreign key (priceCateId)
      references P_CategoryPriceTypes (priceCateId)
         on update cascade on delete cascade
go

alter table P_PriceTypeOneselfPermission
   add constraint FK_P_PRICET_REFERENCE_P_CATEGO2 foreign key (priceCateId)
      references P_CategoryPriceTypes (priceCateId)
         on update cascade on delete cascade
go

alter table P_PriceViewHistory
   add constraint FK_P_PRICEV_REFERENCE_P_PRODUC foreign key (productId)
      references P_Products (productId)
go

alter table P_ProductPrices
   add constraint FK_P_PRODUC_REFERENCE_P_CATEGO foreign key (priceCateId)
      references P_CategoryPriceTypes (priceCateId)
         on update cascade on delete cascade
go

alter table P_ProductPrices
   add constraint FK_P_PRODUC_REFERENCE_P_PRODUC foreign key (productId)
      references P_Products (productId)
         on update cascade on delete cascade
go

alter table P_Products
   add constraint FK_P_PRODUC_REFERENCE_P_SYSBRA foreign key (brid)
      references P_SysBrandRelationship (brid)
go

alter table P_SysBrandRelationship
   add constraint FK_P_SYSBRA_REFERENCE_P_SYSBRA foreign key (brandId)
      references P_SysBrandLibrary (brandId)
         on update cascade on delete cascade
go

alter table P_SysBrandRelationship
   add constraint FK_P_SYSBRA_REFERENCE_P_SYSPRO foreign key (cateid)
      references P_SysProductCategory (cateid)
go

alter table sys_lastUpdates
   add constraint FK_SYS_LAST_REFERENCE_SYS_LAST foreign key (keyId)
      references sys_lastupdatekeys (keyID)
go


CREATE TRIGGER t_PRC_DeleteFolder
ON P_ProductFolders
FOR DELETE AS 
	IF(EXISTS(SELECT * FROM P_ProductFolders WHERE pFolderId IN (SELECT FolderId FROM deleted)))
		DELETE FROM P_ProductFolders WHERE pFolderId IN (SELECT FolderId FROM deleted)
	
	DELETE FROM P_Products WHERE brid IN (SELECT brid FROM deleted) AND uid IN (SELECT uid FROM deleted)
go

