CREATE TABLE [dbo].[ContentScripts] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[Name] [nvarchar] (50) NULL ,
	[Code] [ntext] NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

CREATE TABLE [dbo].[DocumentFields] (
	[FieldID] [int] IDENTITY (1, 1) NOT NULL ,
	[DocID] [int] NULL ,
	[Name] [nvarchar] (64) NULL ,
	[LangId] [int] NOT NULL ,
	[FieldValue] [ntext] NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

CREATE TABLE [dbo].[DocumentLanguages] (
	[dlId] [int] IDENTITY (1, 1) NOT NULL ,
	[DocId] [int] NULL ,
	[LangId] [int] NULL ,
	[DocName] [nvarchar] (50) NULL ,
	[LangStatus] [int] NULL ,
	[LangModuleURL] [nvarchar] (150) NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[Documents] (
	[DocumentID] [int] IDENTITY (1, 1) NOT NULL ,
	[ParentID] [int] NULL ,
	[prevDocumentID] [int] NULL ,
	[prevParentID] [int] NULL ,
	[SortOrder] [int] NULL ,
	[isFolder] [int] NULL ,
	[DocName] [nvarchar] (64) NULL ,
	[ModuleID] [int] NULL ,
	[ModuleFrame] [nvarchar] (100) NULL ,
	[TemplateURL] [nvarchar] (255) NULL ,
	[CreatedBy] [int] NULL ,
	[CreatedDate] [smalldatetime] NULL ,
	[ModifiedBy] [int] NULL ,
	[ModifiedDate] [smalldatetime] NULL ,
	[SentForApprovalDate] [smalldatetime] NULL ,
	[PublishDate] [smalldatetime] NULL ,
	[ExpiresDate] [smalldatetime] NULL ,
	[Active] [int] NULL ,
	[ApprovalID] [int] NULL ,
	[DocumentStatus] [smallint] NULL ,
	[SecLevel] [smallint] NULL ,
	[ExternalPage] [smallint] NULL ,
	[ExternalPageURL] [nvarchar] (250) NULL ,
	[ExternalPageFrame] [nvarchar] (50) NULL ,
	[Extra1] [nvarchar] (25) NULL ,
	[Extra2] [nvarchar] (25) NULL ,
	[Extra3] [nvarchar] (25) NULL ,
	[MultiPageStartYN] [nvarchar] (50) NULL ,
	[MultiPagePrevPage] [smallint] NULL ,
	[MultiPageNextPage] [int] NULL ,
	[TreeIcon] [nvarchar] (25) NULL ,
	[Searchable] [smallint] NOT NULL
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[Documents] ADD 
	CONSTRAINT [DF_Documents_Searchable] DEFAULT (1) FOR [Searchable]
GO

CREATE TABLE [dbo].[FunctionScripts] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[Name] [nvarchar] (50) NULL ,
	[Code] [ntext] NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

CREATE TABLE [dbo].[Languages] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[Code] [nvarchar] (3) NULL ,
	[Description] [nvarchar] (50) NULL ,
	[MasterLanguage] [int] NULL ,
	[LCID] [int] NULL ,
	[Charset] [nvarchar] (20) NULL ,
	[LanguageImage] [nvarchar] (150) NULL ,
	[IsMenuDirty] [int] NULL , 
	[SiteTitle] [nvarchar] (250) NULL ,
	[ShowFlag] [smallint] NULL
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[Members] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[Email] [nvarchar] (100) NULL ,
	[MemberPassword] [nvarchar] (15) NULL ,
	[Nickname] [nvarchar] (50) NULL ,
	[MemberLevel] [int] NULL ,
	[Status] [int] NULL ,
	[Registred] [smalldatetime] NULL ,
	[LastLoggin] [smalldatetime] NULL ,
	[LoginCount] [int] NULL ,
	[Firstname] [nvarchar] (75) NULL ,
	[LastName] [nvarchar] (100) NULL ,
	[Company] [nvarchar] (100) NULL ,
	[JobTitle] [nvarchar] (50) NULL ,
	[Phone] [nvarchar] (50) NULL ,
	[Street1] [nvarchar] (75) NULL ,
	[Street2] [nvarchar] (75) NULL ,
	[City] [nvarchar] (100) NULL ,
	[State] [nvarchar] (2) NULL ,
	[ZipCode] [nvarchar] (10) NULL ,
	[Country] [nvarchar] (2) NULL ,
	[MembershipEnds] [smalldatetime] NULL ,
	[NewsLetter] [int] NULL ,
	[Code1] [nvarchar] (10) NULL ,
	[Code2] [nvarchar] (10) NULL ,
	[Code3] [nvarchar] (10) NULL ,
	[Code4] [nvarchar] (10) NULL ,
	[Code5] [nvarchar] (10) NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[Modules] (
	[ModuleID] [int] IDENTITY (1, 1) NOT NULL ,
	[ModuleName] [nvarchar] (50) NULL ,
	[ModuleVersion] [nvarchar] (5) NULL ,
	[StartURL] [nvarchar] (200) NULL ,
	[StartFrame] [nvarchar] (50) NULL ,
	[AdminURL] [nvarchar] (200) NULL ,
	[Active] [smallint] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[SystemData] (
	[sdID] [int] IDENTITY (1, 1) NOT NULL ,
	[OwnerCompany] [nvarchar] (100) NULL ,
	[OwnerName] [nvarchar] (100) NULL ,
	[OwnerEmail] [nvarchar] (100) NULL ,
	[OwnerSiteID] [nvarchar] (10) NULL ,
	[VersionType] [nvarchar] (255) NULL ,
	[VersionNumber] [nvarchar] (10) NULL ,
	[VersionBuild] [nvarchar] (10) NULL ,
	[DealerID] [nvarchar] (10) NULL ,
	[HostingID] [nvarchar] (50) NULL ,
	[swoAccountID] [nvarchar] (15) NULL ,
	[swoURL] [nvarchar] (150) NULL ,
	[swoLoggin] [nvarchar] (20) NULL ,
	[swoPassword] [nvarchar] (20) NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[Tasks] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[OwnerID] [int] NULL ,
	[OwnerGroupID] [int] NULL ,
	[CreatedByID] [int] NULL ,
	[DocumentID] [int] NULL ,
	[RevisionID] [int] NULL ,
	[Prio] [int] NULL ,
	[Status] [int] NULL ,
	[Subject] [nvarchar] (50) NULL ,
	[DueDate] [smalldatetime] NULL ,
	[Description] [nvarchar] (200) NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[UserGroups] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[Description] [nvarchar] (50) NULL ,
	[vRead] [smallint] NULL ,
	[vCreate] [smallint] NULL ,
	[vEdit] [smallint] NULL ,
	[vDelete] [smallint] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[Users] (
	[UserID] [int] IDENTITY (1, 1) NOT NULL ,
	[FirstName] [nvarchar] (50) NULL ,
	[LastName] [nvarchar] (50) NULL ,
	[LoginName] [nvarchar] (50) NULL ,
	[LoginPassword] [nvarchar] (50) NULL ,
	[Email] [nvarchar] (50) NULL ,
	[Expires] [smalldatetime] NULL ,
	[UserType] [int] NULL ,
	[Address1] [nvarchar] (50) NULL ,
	[Address2] [nvarchar] (50) NULL ,
	[Address3] [nvarchar] (50) NULL ,
	[Department] [nvarchar] (30) NULL ,
	[Phone] [nvarchar] (50) NULL ,
	[ntName] [nvarchar] (80) NULL ,
	[EmailApprovalInfoYN] [int] NULL ,
	[UserGroup] [int] NULL ,
	[isPublisher] [smallint] NULL ,
	[EditorWidth] [int] NULL ,
	[EditorWidthType] [int] NULL ,
	[EditorHeight] [int] NULL ,
	[EditorHeightType] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[WorkFlowInfo] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[DocID] [int] NULL ,
	[UserID] [int] NULL ,
	[LangID] [int] NULL ,
	[ApprovalUserID] [int] NULL ,
	[Status] [int] NULL ,
	[Info] [nvarchar] (254) NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[cmsSettings] (
	[ID] [int] IDENTITY (1, 1) NOT NULL ,
	[SettingKey] [nvarchar] (50) NULL ,
	[SettingValue] [nvarchar] (200) NULL ,
	[SettingType] [nvarchar] (15) NULL ,
	[SettingIsReadOnly] [smallint] NULL ,
	[SettingOptions] [nvarchar] (200) NULL ,
	[SettingComments] [nvarchar] (200) NULL ,
	[SettingGroup] [nvarchar] (50) NULL 
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[ContentScripts] WITH NOCHECK ADD 
	CONSTRAINT [PK_ContentScripts] PRIMARY KEY
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[DocumentFields] WITH NOCHECK ADD 
	CONSTRAINT [PK_DocumentFields] PRIMARY KEY
	(
		[FieldID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[DocumentLanguages] WITH NOCHECK ADD 
	CONSTRAINT [PK_DocumentLanguages] PRIMARY KEY
	(
		[dlId]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[Documents] WITH NOCHECK ADD 
	CONSTRAINT [PK_Documents] PRIMARY KEY
	(
		[DocumentID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[FunctionScripts] WITH NOCHECK ADD 
	CONSTRAINT [PK_FunctionScripts] PRIMARY KEY
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[Languages] WITH NOCHECK ADD 
	CONSTRAINT [PK_Languages] PRIMARY KEY
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[Members] WITH NOCHECK ADD 
	CONSTRAINT [PK_Members] PRIMARY KEY
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[Modules] WITH NOCHECK ADD 
	CONSTRAINT [PK_Modules] PRIMARY KEY
	(
		[ModuleID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[SystemData] WITH NOCHECK ADD 
	CONSTRAINT [PK_SystemData] PRIMARY KEY
	(
		[sdID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[Tasks] WITH NOCHECK ADD 
	CONSTRAINT [PK_Tasks] PRIMARY KEY
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[UserGroups] WITH NOCHECK ADD 
	CONSTRAINT [PK_UserGroups] PRIMARY KEY
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[Users] WITH NOCHECK ADD 
	CONSTRAINT [PK_Users] PRIMARY KEY
	(
		[UserID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[WorkFlowInfo] WITH NOCHECK ADD 
	CONSTRAINT [PK_WorkFlowInfo] PRIMARY KEY
	(
		[ID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[cmsSettings] WITH NOCHECK ADD 
	CONSTRAINT [PK_cmsSettings] PRIMARY KEY
	(
		[ID]
	)  ON [PRIMARY] 
GO

