/*==============================================================*/
/* DBMS name:      Sybase AS Enterprise 12.5.2                  */
/* Created on:     2006-9-1 13:44:24                            */
/*==============================================================*/


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


/*==============================================================*/
/* Table: ACLENTRIES_2                                          */
/*==============================================================*/
create table ACLENTRIES_2 (
   ENTRY_ID             INT                            not null,
   ACL_ID               INT                            null,
   PRINCIPAL_TYPE       TINYINT                        null,
   PRINCIPAL_NAME       VARCHAR(64)                    null,
   IS_POSITIVE          BIT                            ,
   PERMISSIONS          INT                            null,
   constraint PK_ACLENTRIES_2 primary key (ENTRY_ID)
)
go

/*==============================================================*/
/* Table: ACLS_2                                                */
/*==============================================================*/
create table ACLS_2 (
   ID                   INT                            not null,
   NAME                 VARCHAR(64)                    null,
   CREATE_NAME          VARCHAR(32)                    null,
   CREATE_TIME          REAL                           null,
   constraint PK_ACLS_2 primary key (ID)
)
go

/*==============================================================*/
/* Table: ACLS_WITH_RESOURCE_1                                  */
/*==============================================================*/
create table ACLS_WITH_RESOURCE_1 (
   ID                   INT                            not null,
   RESOURCE_PATH        VARCHAR(255)                   null,
   VERSION_NUMBER       INT                            null,
   ACL_NAME             VARCHAR(64)                    null,
   CREATE_NAME          VARCHAR(32)                    null,
   CREATE_TIME          REAL                           null,
   constraint PK_ACLS_WITH_RESOURCE_1 primary key (ID)
)
go

/*==============================================================*/
/* Table: ALIASES_1                                             */
/*==============================================================*/
create table ALIASES_1 (
   ID                   INT                            null,
   PRINCIPAL_NAME       VARCHAR(128)                   null,
   PRINCIPAL_TYPE       TINYINT                        null,
   ALIAS_NAME           VARCHAR(255)                   null,
   PARENT_NAME          VARCHAR(255)                   null,
   MAP_RESOURCE         VARCHAR(255)                   null,
   HIDDEN               BIT                            ,
   constraint AK_KEY_1_ALIASES_ unique (ID)
)
go

/*==============================================================*/
/* Table: CATALOGVERSION_2                                      */
/*==============================================================*/
create table CATALOGVERSION_2 (
   VERSIONNUMBER        INT                            null,
   VERSIONNAME          VARCHAR(128)                   null,
   RESOURCEID           INT                            null,
   CREATOR              VARCHAR(128)                   null,
   CREATEDTIME          REAL                           null,
   MODIFIER             VARCHAR(128)                   null,
   MODIFIEDTIME         REAL                           null,
   CATALOGFILE          VARCHAR(128)                   null,
   ID                   REAL                           null,
   constraint AK_KEY_1_CATALOGV unique (ID)
)
go

/*==============================================================*/
/* Table: COMPLETEDPUBLISHTABLE_2                               */
/*==============================================================*/
create table COMPLETEDPUBLISHTABLE_2 (
   ID                   INT                            null,
   RECORDID             VARCHAR(40)                    null,
   SHEETNAME            VARCHAR(255)                   null,
   DISPLAYNAME          VARCHAR(255)                   null,
   PUB_TYPE             VARCHAR(64)                    null
)
go

/*==============================================================*/
/* Table: COMPLETEDRESULTTABLE_3                                */
/*==============================================================*/
create table COMPLETEDRESULTTABLE_3 (
   PUBLISHID            INT                            null,
   RECORDID             VARCHAR(40)                    null,
   PUB_TYPE             VARCHAR(128)                    null,
   STATUS               INT                            null,
   DETAIL               VARCHAR(255)                   null
)
go

/*==============================================================*/
/* Table: COMPLETEDTABLE_4                                      */
/*==============================================================*/
create table COMPLETEDTABLE_4 (
   ID                   INT                            null,
   RECORDID             VARCHAR(128)                   null,
   TASKID               VARCHAR(128)                   null,
   TASKCLASS            VARCHAR(255)                   null,
   CATFILE              VARCHAR(255)                   null,
   RPTFILE              VARCHAR(255)                   null,
   PARAMFILE            VARCHAR(255)                   null,
   RESULTFILE           VARCHAR(255)                   null,
   ERROR                VARCHAR(255)                   null,
   ENGMSG               VARCHAR(255)                   null,
   SUBMITTER            VARCHAR(128)                   null,
   COMPLETEDTIME        REAL                           null,
   FORMATEXISTS         INT                            null,
   FORMATSUCCESSFUL     INT                            null,
   VERSIONID            INT                            null,
   LAUNCHTYPE           INT                            null,
   ISSUCCESSFUL         BIT                            ,
   TASKNAME             VARCHAR(128)                   null,
   ISMISSED             BIT                            ,
   SCHEDULETRIGGER      VARCHAR(80)                    null,
   CONDITIONSLOGIC      VARCHAR(16)                    null,
   REPORTNAMES          VARCHAR(255)                   null
)
go

/*==============================================================*/
/* Table: DRESULT_2                                             */
/*==============================================================*/
create table DRESULT_2 (
   REPORTSET            VARCHAR(128)                   null,
   VERSIONNUMBER        REAL                           null,
   REPORT               VARCHAR(128)                   null,
   REPORTDISPLAYNAME    VARCHAR(128)                   null,
   RESULT               VARCHAR(128)                   null,
   VIEWEDFORMATS        REAL,
   PLSRESULTFMTS        REAL,
   SECCONSTRAINTFMTS    REAL
)
go

/*==============================================================*/
/* Table: DYNAMICNODE_2                                         */
/*==============================================================*/
create table DYNAMICNODE_2 (
   NAME                 VARCHAR(128)                   null,
   ROOT                 VARCHAR(128)                   null,
   REALPATH             VARCHAR(255)                   null,
   NODETYPE             TINYINT                        null,
   ENABLEARCHIVEPOLICY  BIT                            ,
   DELETED              BIT                            ,
   ACLID                INT                            null,
   DESCRIPTION          VARCHAR(255)                   null,
   MAXVERSIONAMOUNT     INT                            null,
   ENABLELINKEDCAT      BIT                            null, 
   LINKEDCAT            VARCHAR(255)		           null, 
   USEINHERITED         BIT                            null

   
)
go

/*==============================================================*/
/* Table: DYNAMICRESULT_1                                       */
/*==============================================================*/
create table DYNAMICRESULT_1 (
   ID                   INT                            null,
   REPORTNAME           VARCHAR(128)                   null,
   VERSIONNUMBER        INT                            null,
   CREATOR              VARCHAR(128)                   null,
   CREATEDTIME          REAL                           null,
   CATALOGVERNUM        INT                            null,
   CATALOGRESNUM        INT                            null,
   REPORTVERNUM         INT                            null,
   REPORTRESNUM         INT                            null,
   PARAMFILE            VARCHAR(128)                   null,
   RESULTFILE           VARCHAR(128)                   null,
   RESULTFMTS           REAL                           null,
   LAUNCHTYPE           INT                            null,
   TASKID               VARCHAR(128)                   null,
   EXPIRATIONTIME       REAL                           null,
   EXPIRE               BIT                            ,
   EXPIRATIONMETHOD     INT                            null,
   REPORTAMOUNT         INT                            null
)
go

/*==============================================================*/
/* Table: EXTENDACLENTRIES_2                                    */
/*==============================================================*/
create table EXTENDACLENTRIES_2 (
   PRINCIPAL_NAME       VARCHAR(64)                    null,
   PRINCIPAL_TYPE       TINYINT                        null,
   PERMISSIONS          INT                            null,
   constraint AK_KEY_1_EXTENDAC unique (PRINCIPAL_NAME, PRINCIPAL_TYPE)
)
go

/*==============================================================*/
/* Table: FOLDERS_3                                             */
/*==============================================================*/
create table FOLDERS_3 (
   ID                   INT                            null,
   REALPATH             VARCHAR(255)                   null,
   OWNERNAME            VARCHAR(32)                    null,
   MAXVERSIONAMOUNT     INT                            null,
   ARCHIVENEWVERSION    BIT                            ,
   ENABLEARCHIVEPOLICY  BIT                            ,
   IS_SHARED            BIT                            ,
   ENABLEDYNAMICRESOURCE BIT                            
)
go

/*==============================================================*/
/* Table: GROUPPROFILES_1                                       */
/*==============================================================*/
create table GROUPPROFILES_1 (
   GROUP_NAME           VARCHAR(32)                    null,
   SUB_GROUP_NAME       VARCHAR(32)                    null
)
go

/*==============================================================*/
/* Table: GROUPS_1                                              */
/*==============================================================*/
create table GROUPS_1 (
   NAME                 VARCHAR(32)                    not null,
   BUILDIN              BIT                            ,
   DESCRIPTION          VARCHAR(32)                    null,
   GROUP_TYPE           INT                            null,
   constraint PK_GROUPS_1 primary key (NAME)
)
go

/*==============================================================*/
/* Table: GUPROFILES_1                                          */
/*==============================================================*/
create table GUPROFILES_1 (
   GROUP_NAME           VARCHAR(32)                    null,
   USER_NAME            VARCHAR(32)                    null
)
go

/*==============================================================*/
/* Table: NODES_3                                               */
/*==============================================================*/
create table NODES_3 (
   ID                   INT                            null,
   NAME                 VARCHAR(64)                    null,
   CREATORNAME          VARCHAR(32)                    null,
   CREATETIME           REAL                           null,
   PARENTID             INT                            null,
   NODETYPE             TINYINT                        null,
   ACLID                INT                            null,
   DESCRIPTION          VARCHAR(255)                   null,
   ENABLELINKEDCAT      BIT, 
   LINKEDCAT            VARCHAR(255), 
   USEINHERITED         BIT
)
go

/*==============================================================*/
/* Table: REPORTVERSION_2                                       */
/*==============================================================*/
create table REPORTVERSION_2 (
   VERSIONNUMBER        INT                            null,
   VERSIONNAME          VARCHAR(128)                   null,
   RESOURCEID           INT                            null,
   CREATOR              VARCHAR(128)                   null,
   CREATETIME           REAL                           null,
   MODIFIER             VARCHAR(128)                   null,
   MODIFIEDTIME         REAL                           null,
   REPORTFILE           VARCHAR(128)                   null,
   ID                   REAL                           null,
   constraint AK_KEY_1_REPORTVE unique (RESOURCEID, ID)
)
go

/*==============================================================*/
/* Table: RESOURCEMAP_1                                         */
/*==============================================================*/
create table RESOURCEMAP_1 (
   RESOURCEID           INT                            null,
   RESOURCENAME         VARCHAR(128)                   null,
   RESOURCETYPE         TINYINT                        null
)
go

/*==============================================================*/
/* Table: RESOURCENODES_3                                       */
/*==============================================================*/
create table RESOURCENODES_3 (
   ID                   INT                            null,
   RESOURCETYPE         TINYINT                        null,
   REALPATH             VARCHAR(255)                   null,
   MAXVERSIONAMOUNT     INT                            null,
   ARCHIVENEWVERSION    BIT                            ,
   ENABLEARCHIVEPOLICY  BIT                         ,
   PROFILENAME             VARCHAR(255)            
)
go

/*==============================================================*/
/* Table: RESULTVERSION_2                                       */
/*==============================================================*/
create table RESULTVERSION_2 (
   ID                   REAL                           null,
   VERSIONNUMBER        INT                            null,
   VERSIONNAME          VARCHAR(128)                   null,
   RESOURCEID           INT                            null,
   CREATOR              VARCHAR(128)                   null,
   CREATEDTIME          REAL                           null,
   MODIFIER             VARCHAR(128)                   null,
   MODIFIEDTIME         REAL                           null,
   CATALOGVERNUM        INT                            null,
   CATALOGRESNUM        INT                            null,
   REPORTVERNUM         INT                            null,
   REPORTRESNUM         INT                            null,
   PARAMFILE            VARCHAR(128)                   null,
   RESULTFILE           VARCHAR(128)                   null,
   RESULTFMTS           REAL                           null,
   LAUNCHTYPE           INT                            null,
   TASKID               VARCHAR(128)                   null,
   EXPIRATIONTIME       REAL                           null,
   EXPIRE               BIT                            ,
   EXPIREATIONMETHOD    INT                            null,
   SPECIFIEDFOLDER      VARCHAR(128)                   null,
   REPORTAMOUNT         INT                            null,
   constraint AK_KEY_1_RESULTVE unique (ID, RESOURCEID)
)
go

/*==============================================================*/
/* Table: RESULT_2                                              */
/*==============================================================*/
create table RESULT_2 (
   RESOURCEID           REAL                           null,
   VERSIONNUMBER        REAL                           null,
   REPORT               VARCHAR(128)                   null,
   REPORTDISPLAYNAME    VARCHAR(128)                   null,
   RESULT               VARCHAR(128)                   null,
   VIEWEDFORMATS        REAL,
   PLSRESULTFMTS        REAL,
   SECCONSTRAINTFMTS    REAL
)
go

/*==============================================================*/
/* Table: RGPROFILES_1                                          */
/*==============================================================*/
create table RGPROFILES_1 (
   ROLE_NAME            VARCHAR(32)                    null,
   GROUP_NAME           VARCHAR(32)                    null
)
go

/*==============================================================*/
/* Table: ROLEPROFILES_2                                        */
/*==============================================================*/
create table ROLEPROFILES_2 (
   ROLE_NAME            VARCHAR(32)                    null,
   SUB_ROLE_NAME        VARCHAR(32)                    null
)
go

/*==============================================================*/
/* Table: ROLES_2                                               */
/*==============================================================*/
create table ROLES_2 (
   NAME                 VARCHAR(32)                    not null,
   BUILDIN              BIT                            ,
   DESCRIPTION          VARCHAR(32)                    null,
   ROLE_TYPE            INT                            null,
   constraint PK_ROLES_2 primary key (NAME)
)
go

/*==============================================================*/
/* Table: SCHDLASTEXETIME_1                                     */
/*==============================================================*/
create table SCHDLASTEXETIME_1 (
   TASKID               VARCHAR(40)                    null,
   LASTEXETIME          REAL                           null
)
go

/*==============================================================*/
/* Table: TBL_IDGENRATOR_JINFONET                               */
/*==============================================================*/
create table TBL_IDGENRATOR_JINFONET (
   TF_NAME              VARCHAR(64)                    not null,
   NEXT_ID              INT                            null,
   constraint PK_TBL_IDGENRATOR_JINFONET primary key (TF_NAME)
)
go

/*==============================================================*/
/* Table: TRIGGERS_1                                            */
/*==============================================================*/
create table TRIGGERS_1 (
   TRIGGER_NAME         VARCHAR(80)                    not null,
   DESCRIPTION          VARCHAR(255)                   null,
   TRIGGER_TYPE         TINYINT                        null,
   TRIGGER_STATE        BIT                            ,
   PREV_FIRE_TIME       REAL                           null,
   NEXT_FIRE_TIME       REAL                           null,
   constraint PK_TRIGGERS_1 primary key (TRIGGER_NAME)
)
go

/*==============================================================*/
/* Table: UPDATEDETAILS_1                                       */
/*==============================================================*/
create table UPDATEDETAILS_1 (
   UPDATE_ITEM          VARCHAR(32)                    not null,
   UPDATE_STATE         BIT                            ,
   constraint PK_UPDATEDETAILS_1 primary key (UPDATE_ITEM)
)
go

/*==============================================================*/
/* Table: USERPROFILES_2                                        */
/*==============================================================*/
create table USERPROFILES_2 (
   USER_NAME            VARCHAR(32)                    null,
   ROLE_NAME            VARCHAR(32)                    null
)
go

/*==============================================================*/
/* Table: USERS_3                                               */
/*==============================================================*/
create table USERS_3 (
   NAME                 VARCHAR(32)                    not null,
   FULL_NAME            VARCHAR(128)                   null,
   DESCRIPTION          VARCHAR(128)                   null,
   EMAIL                VARCHAR(128)                   null,
   CREATE_TIME          REAL                           null,
   USER_PSWD            VARCHAR(128)                   null,
   BUILDIN              BIT                            ,
   ENABLE               BIT                            ,
   MIN_PS_LENGTH        INT                            null,
   LAST_MODIFY_TIME     REAL                           null,
   NEVER_EXPIRE         BIT,
   EXPIRE_TIME          INT                            null,
   ACCOUNT_DISABLE      BIT,
   ACCESS_EVENT_SUC     BIT,
   ACCESS_EVENT_FAIL    BIT,
   MANAGEMENT_EVENT_SUC BIT,
   MANAGEMENT_EVENT_FAIL BIT,
   NO_AUDIT             BIT,
   AUTH_TYPE            INT                            null,
   LDAP_TYPE            INT                            null,
   constraint PK_USERS_3 primary key (NAME)
)
go

/*==============================================================*/
/* Table: VERSIONNODES_2                                        */
/*==============================================================*/
create table VERSIONNODES_2 (
   ID                   INT                            null,
   RESOURCEID           INT                            null,
   VERSIONNUMBER        INT                            null,
   EXPIRATIONTIME       REAL                           null
)
go

/*==============================================================*/
/* Table: TASKCONTEXT                                        	*/
/* FOR PROFILING												*/
/*==============================================================*/
CREATE TABLE TASKCONTEXT (
	ID 					INT NOT NULL,
	VS_RPT_NAME 		VARCHAR(255),
	VI_TSK_TYPE 		INT,
	VI_TSK_STATUS 		INT,
	TS_TSK_SUBMIT 		DATETIME,
	TS_ENG_START 		DATETIME,
	TS_ENG_EXITS 		DATETIME,
	TS_TSK_COMPLETE 	DATETIME,
	TC_TSK_TOTAL 		REAL,
	TC_TSK_WAITED 		REAL,
	TC_ENG_TOTAL 		REAL,
	TC_ENG_LOAD 		REAL,
	TC_ENG_EXPORT 		REAL,
	TC_ENG_OTHER 		REAL,
	TC_TSK_OTHER 		REAL,
	NC_RPT_PAGES 		REAL,
	NC_RPT_FORMATS 		REAL,
	NC_ENG_CONCURRENT 	REAL,
	NC_QUE_LENGTH 		REAL, 
	PRIMARY KEY(ID)
)
go

INSERT INTO TBL_IDGENRATOR_JINFONET (TF_NAME,NEXT_ID) VALUES ('NODES_3_ID',0)
go

INSERT INTO TBL_IDGENRATOR_JINFONET (TF_NAME,NEXT_ID) VALUES ('CATALOGVERSION_2_ID',0)
go

INSERT INTO TBL_IDGENRATOR_JINFONET (TF_NAME,NEXT_ID) VALUES ('REPORTVERSION_2_ID',0)
go

INSERT INTO TBL_IDGENRATOR_JINFONET (TF_NAME,NEXT_ID) VALUES ('RESULTVERSION_2_ID',0)
go

INSERT INTO TBL_IDGENRATOR_JINFONET (TF_NAME,NEXT_ID) VALUES ('ACLS_2_ID',0)
go

INSERT INTO TBL_IDGENRATOR_JINFONET (TF_NAME,NEXT_ID) VALUES ('ACLENTRIES_2_ENTRY_ID',0)
go

INSERT INTO TBL_IDGENRATOR_JINFONET (TF_NAME,NEXT_ID) VALUES ('COMPLETEDTABLE_4_ID',0)
go

INSERT INTO TBL_IDGENRATOR_JINFONET (TF_NAME,NEXT_ID) VALUES ('ACLS_WITH_RESOURCE_1_ID',0)
go

