/* Script generated by dbschema.pl(2.4.2) on Thu Jan  3 09:38:55 2008.  */
/* Script extracted on a linux system. */

use <dbname>
go

/* Aliases... */

/* No aliases found. */

/* Add user-defined data types: */

/* No user defined types found. */


/* Rules... */

/* No rules found. */

/* Defaults... */

/* Default one_def, owner dbo */
IF OBJECT_ID('dbo.one_def') IS NOT NULL
BEGIN

    setuser 'dbo'

    DROP DEFAULT dbo.one_def

END
go

setuser 'dbo'
go
create default one_def as 1
go

/* Default zero_def, owner dbo */
IF OBJECT_ID('dbo.zero_def') IS NOT NULL
BEGIN

    setuser 'dbo'

    DROP DEFAULT dbo.zero_def

END
go

setuser 'dbo'
go
create default zero_def as 0
go

/* Bind rules & defaults to user data types... */

/* No defaults to bind. */

/* No rules to bind. */


/* Start of description of table dbo.Genome */

setuser 'dbo'
go

IF OBJECT_ID('dbo.Genome') IS NOT NULL
BEGIN
    DROP TABLE dbo.Genome
END
go

CREATE TABLE dbo.Genome (
	ID      bigint       IDENTITY,
	Study   varchar(100)     NULL,
	Project varchar(100)     NULL,
	Taxon   varchar(50)      NULL
)
LOCK DATAPAGES
go

IF OBJECT_ID('dbo.Genome') IS NOT NULL
    ALTER TABLE dbo.Genome PARTITION 2
go

IF EXISTS(SELECT 1 FROM sysindexes
           WHERE name = 'pk_Genome'
             AND id   = OBJECT_ID('dbo.Genome'))
BEGIN
    DROP INDEX Genome.pk_Genome
END
go

IF OBJECT_ID('dbo.Genome') IS NOT NULL
BEGIN
    CREATE UNIQUE NONCLUSTERED INDEX pk_Genome
    ON Genome (ID)
END
go


/* Add permissions for table... */
IF OBJECT_ID('dbo.Genome') IS NOT NULL
BEGIN
    GRANT ALL,UPDATE STATISTICS ON dbo.Genome TO public
END
go

/* Bind rules & defaults to columns... */
/* End of description of table dbo.Genome */


/* Start of description of table dbo.Assembly */

setuser 'dbo'
go

IF OBJECT_ID('dbo.Assembly') IS NOT NULL
BEGIN
    DROP TABLE dbo.Assembly
END
go

CREATE TABLE dbo.Assembly (
	ID                bigint        IDENTITY,
	Creation          smalldatetime     NULL,
	Genome_ID         bigint            NULL,
	Operator          varchar(30)       NULL,
	GeneratingProgram varchar(50)       NULL,
	ProgramVersion    varchar(20)       NULL,
	Status            char(1)           NULL,
	Notes             varchar(2000)     NULL,
    CONSTRAINT fk_Assembly_Genome FOREIGN KEY (Genome_ID) REFERENCES dbo.Genome (ID)
)
LOCK DATAPAGES
go

IF OBJECT_ID('dbo.Assembly') IS NOT NULL
    ALTER TABLE dbo.Assembly PARTITION 2
go

IF EXISTS(SELECT 1 FROM sysindexes
           WHERE name = 'pk_Assembly'
             AND id   = OBJECT_ID('dbo.Assembly'))
BEGIN
    DROP INDEX Assembly.pk_Assembly
END
go

IF OBJECT_ID('dbo.Assembly') IS NOT NULL
BEGIN
    CREATE UNIQUE NONCLUSTERED INDEX pk_Assembly
    ON Assembly (ID)
END
go


/* Add permissions for table... */
IF OBJECT_ID('dbo.Assembly') IS NOT NULL
BEGIN
    GRANT ALL,UPDATE STATISTICS ON dbo.Assembly TO public
END
go

/* Bind rules & defaults to columns... */
/* End of description of table dbo.Assembly */


/* Start of description of table dbo.AFG */

setuser 'dbo'
go

IF OBJECT_ID('dbo.AFG') IS NOT NULL
BEGIN
    DROP TABLE dbo.AFG
END
go

CREATE TABLE dbo.AFG (
	afg_MSG_ID     bigint   IDENTITY,
	afg_AssemblyID bigint       NULL,
	afg_EUID       char(32)     NULL,
	afg_CIID       uint         NULL,
	afg_mst        char(1)      NULL,
	afg_chi        bit      NOT NULL,
	afg_cha        bit      NOT NULL,
	afg_clr1       smallint     NULL,
	afg_clr2       smallint     NULL,
    CONSTRAINT fk_AFG_Assembly FOREIGN KEY (afg_AssemblyID) REFERENCES dbo.Assembly (ID)
)
LOCK DATAPAGES
go

IF OBJECT_ID('dbo.AFG') IS NOT NULL
    ALTER TABLE dbo.AFG PARTITION 2
go

IF EXISTS(SELECT 1 FROM sysindexes
           WHERE name = 'pk_AFG'
             AND id   = OBJECT_ID('dbo.AFG'))
BEGIN
    DROP INDEX AFG.pk_AFG
END
go

IF OBJECT_ID('dbo.AFG') IS NOT NULL
BEGIN
    CREATE UNIQUE NONCLUSTERED INDEX pk_AFG
    ON AFG (afg_MSG_ID)
END
go


/* Add permissions for table... */
IF OBJECT_ID('dbo.AFG') IS NOT NULL
BEGIN
    GRANT ALL,UPDATE STATISTICS ON dbo.AFG TO public
END
go

/* Bind rules & defaults to columns... */
/* End of description of table dbo.AFG */


/* Start of description of table dbo.CCO */

setuser 'dbo'
go

IF OBJECT_ID('dbo.CCO') IS NOT NULL
BEGIN
    DROP TABLE dbo.CCO
END
go

CREATE TABLE dbo.CCO (
	cco_MSG_ID     bigint        IDENTITY,
	cco_AssemblyID bigint            NULL,
	cco_EUID       char(32)          NULL,
	cco_CIID       uint              NULL,
	cco_pla        varchar(255)      NULL,
	cco_len        int               NULL,
	cco_cns        varchar(1000)     NULL,
	cco_qlt        varchar(1000)     NULL,
	cco_for        bit           NOT NULL,
	cco_npc        int               NULL,
	cco_nou        int               NULL,
	cco_nvr        int               NULL
)
LOCK DATAPAGES
go

IF OBJECT_ID('dbo.CCO') IS NOT NULL
    ALTER TABLE dbo.CCO PARTITION 1
go

/* Add permissions for table... */
IF OBJECT_ID('dbo.CCO') IS NOT NULL
BEGIN
    GRANT ALL,UPDATE STATISTICS ON dbo.CCO TO public
END
go

/* Bind rules & defaults to columns... */
exec sp_bindefault zero_def, 'CCO.cco_for'
go
/* End of description of table dbo.CCO */


/* Start of description of table dbo.CCO_MPS */

setuser 'dbo'
go

IF OBJECT_ID('dbo.CCO_MPS') IS NOT NULL
BEGIN
    DROP TABLE dbo.CCO_MPS
END
go

CREATE TABLE dbo.CCO_MPS (
	cco_mps_MSG_ID     bigint        IDENTITY,
	cco_mps_AssemblyID bigint            NULL,
	cco_mps_EUID       char(32)          NULL,
	cco_mps_CIID       uint              NULL,
	cco_mps_cco_MSG_ID bigint            NULL,
	cco_mps_mid        bigint            NULL,
	cco_mps_type       char(1)           NULL,
	cco_mps_src        varchar(1000)     NULL,
	cco_mps_pos1       int               NULL,
	cco_mps_pos2       int               NULL,
	cco_mps_del        varchar(1000)     NULL
)
LOCK DATAPAGES
go

IF OBJECT_ID('dbo.CCO_MPS') IS NOT NULL
    ALTER TABLE dbo.CCO_MPS PARTITION 1
go

/* Add permissions for table... */
IF OBJECT_ID('dbo.CCO_MPS') IS NOT NULL
BEGIN
    GRANT ALL,UPDATE STATISTICS ON dbo.CCO_MPS TO public
END
go

/* Bind rules & defaults to columns... */
/* End of description of table dbo.CCO_MPS */


/* Start of description of table dbo.CLK */

setuser 'dbo'
go

IF OBJECT_ID('dbo.CLK') IS NOT NULL
BEGIN
    DROP TABLE dbo.CLK
END
go

CREATE TABLE dbo.CLK (
	clk_MSG_ID     bigint   IDENTITY,
	clk_AssemblyID bigint       NULL,
	clk_EUID       char(32)     NULL,
	clk_CIID       uint         NULL,
	clk_ori        char(1)      NULL,
	clk_ovt        char(1)      NULL,
	clk_ipc        bit      NOT NULL,
	clk_gui        bit      NOT NULL,
	clk_mea        float(16)     NULL,
	clk_std        float(16)     NULL,
	clk_num        int          NULL,
	clk_sta        char(1)      NULL
)
LOCK DATAPAGES
go

IF OBJECT_ID('dbo.CLK') IS NOT NULL
    ALTER TABLE dbo.CLK PARTITION 1
go

/* Add permissions for table... */
IF OBJECT_ID('dbo.CLK') IS NOT NULL
BEGIN
    GRANT ALL,UPDATE STATISTICS ON dbo.CLK TO public
END
go

/* Bind rules & defaults to columns... */
/* End of description of table dbo.CLK */


/* Start of description of table dbo.CLK_JMP */

setuser 'dbo'
go

IF OBJECT_ID('dbo.CLK_JMP') IS NOT NULL
BEGIN
    DROP TABLE dbo.CLK_JMP
END
go

CREATE TABLE dbo.CLK_JMP (
	clk_jmp_MSG_ID     bigint   IDENTITY,
	clk_jmp_AssemblyID bigint       NULL,
	clk_jmp_EUID       char(32)     NULL,
	clk_jmp_CIID       uint         NULL,
	clk_jmp_cco_MSG_ID bigint       NULL,
	clk_jmp_status     char(1)      NULL
)
LOCK DATAPAGES
go

IF OBJECT_ID('dbo.CLK_JMP') IS NOT NULL
    ALTER TABLE dbo.CLK_JMP PARTITION 1
go

/* Add permissions for table... */
IF OBJECT_ID('dbo.CLK_JMP') IS NOT NULL
BEGIN
    GRANT ALL,UPDATE STATISTICS ON dbo.CLK_JMP TO public
END
go

/* Bind rules & defaults to columns... */
/* End of description of table dbo.CLK_JMP */


/* Start of description of table dbo.CLK_JMP_LIST */

setuser 'dbo'
go

IF OBJECT_ID('dbo.CLK_JMP_LIST') IS NOT NULL
BEGIN
    DROP TABLE dbo.CLK_JMP_LIST
END
go

CREATE TABLE dbo.CLK_JMP_LIST (
	clk_jmp_list_MSG_ID         bigint   IDENTITY,
	clk_jmp_list_AssemblyID     bigint       NULL,
	clk_jmp_list_EUID           char(32)     NULL,
	clk_jmp_list_CIID           uint         NULL,
	clk_jmp_list_clk_jmp_MSG_ID bigint       NULL,
	clk_jmp_list_afg_MSG_ID     bigint       NULL
)
LOCK DATAPAGES
go

IF OBJECT_ID('dbo.CLK_JMP_LIST') IS NOT NULL
    ALTER TABLE dbo.CLK_JMP_LIST PARTITION 1
go

/* Add permissions for table... */
IF OBJECT_ID('dbo.CLK_JMP_LIST') IS NOT NULL
BEGIN
    GRANT ALL,UPDATE STATISTICS ON dbo.CLK_JMP_LIST TO public
END
go

/* Bind rules & defaults to columns... */
/* End of description of table dbo.CLK_JMP_LIST */


/* Start of description of table dbo.CLK_LIST */

setuser 'dbo'
go

IF OBJECT_ID('dbo.CLK_LIST') IS NOT NULL
BEGIN
    DROP TABLE dbo.CLK_LIST
END
go

CREATE TABLE dbo.CLK_LIST (
	clk_list_AssemblyID bigint     NULL,
	clk_list_cco_MSG_ID bigint     NULL,
	clk_list_clk_MSG_ID bigint     NULL
)
LOCK DATAPAGES
go

IF OBJECT_ID('dbo.CLK_LIST') IS NOT NULL
    ALTER TABLE dbo.CLK_LIST PARTITION 1
go

/* Add permissions for table... */
IF OBJECT_ID('dbo.CLK_LIST') IS NOT NULL
BEGIN
    GRANT ALL,UPDATE STATISTICS ON dbo.CLK_LIST TO public
END
go

/* Bind rules & defaults to columns... */
/* End of description of table dbo.CLK_LIST */


/* Start of description of table dbo.CPS */

setuser 'dbo'
go

IF OBJECT_ID('dbo.CPS') IS NOT NULL
BEGIN
    DROP TABLE dbo.CPS
END
go

CREATE TABLE dbo.CPS (
	cps_MSG_ID     bigint   IDENTITY,
	cps_AssemblyID bigint       NULL,
	cps_EUID       char(32)     NULL,
	cps_CIID       uint         NULL,
	cps_ctp_MSG_ID bigint       NULL,
	cps_cco_MSG_ID bigint       NULL,
	cps_pos1       int          NULL,
	cps_pos2       int          NULL
)
LOCK DATAPAGES
go

IF OBJECT_ID('dbo.CPS') IS NOT NULL
    ALTER TABLE dbo.CPS PARTITION 1
go

/* Add permissions for table... */
IF OBJECT_ID('dbo.CPS') IS NOT NULL
BEGIN
    GRANT ALL,UPDATE STATISTICS ON dbo.CPS TO public
END
go

/* Bind rules & defaults to columns... */
/* End of description of table dbo.CPS */


/* Start of description of table dbo.CTP */

setuser 'dbo'
go

IF OBJECT_ID('dbo.CTP') IS NOT NULL
BEGIN
    DROP TABLE dbo.CTP
END
go

CREATE TABLE dbo.CTP (
	ctp_MSG_ID     bigint   IDENTITY,
	ctp_AssemblyID bigint       NULL,
	ctp_EUID       char(32)     NULL,
	ctp_CIID       uint         NULL,
	ctp_scf_MSG_ID bigint       NULL,
	ctp_mea        float(16)     NULL,
	ctp_std        float(16)     NULL,
	ctp_ori        char(1)      NULL
)
LOCK DATAPAGES
go

IF OBJECT_ID('dbo.CTP') IS NOT NULL
    ALTER TABLE dbo.CTP PARTITION 1
go

/* Add permissions for table... */
IF OBJECT_ID('dbo.CTP') IS NOT NULL
BEGIN
    GRANT ALL,UPDATE STATISTICS ON dbo.CTP TO public
END
go

/* Bind rules & defaults to columns... */
/* End of description of table dbo.CTP */


/* Start of description of table dbo.CTP_LIST */

setuser 'dbo'
go

IF OBJECT_ID('dbo.CTP_LIST') IS NOT NULL
BEGIN
    DROP TABLE dbo.CTP_LIST
END
go

CREATE TABLE dbo.CTP_LIST (
	ctp_list_MSG_ID     bigint   IDENTITY,
	ctp_list_AssemblyID bigint       NULL,
	ctp_list_EUID       char(32)     NULL,
	ctp_list_CIID       uint         NULL,
	ctp_list_ctp_MSG_ID bigint       NULL,
	ctp_list_cco_MSG_ID bigint       NULL
)
LOCK DATAPAGES
go

IF OBJECT_ID('dbo.CTP_LIST') IS NOT NULL
    ALTER TABLE dbo.CTP_LIST PARTITION 1
go

/* Add permissions for table... */
IF OBJECT_ID('dbo.CTP_LIST') IS NOT NULL
BEGIN
    GRANT ALL,UPDATE STATISTICS ON dbo.CTP_LIST TO public
END
go

/* Bind rules & defaults to columns... */
/* End of description of table dbo.CTP_LIST */


/* Start of description of table dbo.DSC */

setuser 'dbo'
go

IF OBJECT_ID('dbo.DSC') IS NOT NULL
BEGIN
    DROP TABLE dbo.DSC
END
go

CREATE TABLE dbo.DSC (
	dsc_MSG_ID     bigint   IDENTITY,
	dsc_AssemblyID bigint       NULL,
	dsc_EUID       char(32)     NULL,
	dsc_cco_MSG_ID bigint       NULL
)
LOCK DATAPAGES
go

IF OBJECT_ID('dbo.DSC') IS NOT NULL
    ALTER TABLE dbo.DSC PARTITION 1
go

/* Add permissions for table... */
IF OBJECT_ID('dbo.DSC') IS NOT NULL
BEGIN
    GRANT ALL,UPDATE STATISTICS ON dbo.DSC TO public
END
go

/* Bind rules & defaults to columns... */
/* End of description of table dbo.DSC */


/* Start of description of table dbo.FieldTypes */

setuser 'dbo'
go

IF OBJECT_ID('dbo.FieldTypes') IS NOT NULL
BEGIN
    DROP TABLE dbo.FieldTypes
END
go

CREATE TABLE dbo.FieldTypes (
	MessageTypeId char(3)           NULL,
	FieldTypeID   char(3)           NULL,
	ShortDesc     varchar(50)       NULL,
	LongDesc      varchar(1000)     NULL,
	ValueType     varchar(50)       NULL
)
LOCK DATAPAGES
go

IF OBJECT_ID('dbo.FieldTypes') IS NOT NULL
    ALTER TABLE dbo.FieldTypes PARTITION 1
go

/* Add permissions for table... */
IF OBJECT_ID('dbo.FieldTypes') IS NOT NULL
BEGIN
    GRANT ALL,UPDATE STATISTICS ON dbo.FieldTypes TO public
END
go

/* Bind rules & defaults to columns... */
/* End of description of table dbo.FieldTypes */


/* Start of description of table dbo.JMP */

setuser 'dbo'
go

IF OBJECT_ID('dbo.JMP') IS NOT NULL
BEGIN
    DROP TABLE dbo.JMP
END
go

CREATE TABLE dbo.JMP (
	jmp_MSG_ID     bigint   IDENTITY,
	jmp_AssemblyID bigint       NULL,
	jmp_EUID       char(32)     NULL,
	jmp_CIID       uint         NULL,
	jmp_utg_MSG_ID bigint       NULL,
	jmp_status     char(1)      NULL,
	jmp_type       char(10)     NULL
)
LOCK DATAPAGES
go

IF OBJECT_ID('dbo.JMP') IS NOT NULL
    ALTER TABLE dbo.JMP PARTITION 1
go

/* Add permissions for table... */
IF OBJECT_ID('dbo.JMP') IS NOT NULL
BEGIN
    GRANT ALL,UPDATE STATISTICS ON dbo.JMP TO public
END
go

/* Bind rules & defaults to columns... */
/* End of description of table dbo.JMP */


/* Start of description of table dbo.JMP_LIST */

setuser 'dbo'
go

IF OBJECT_ID('dbo.JMP_LIST') IS NOT NULL
BEGIN
    DROP TABLE dbo.JMP_LIST
END
go

CREATE TABLE dbo.JMP_LIST (
	jmp_list_MSG_ID     bigint   IDENTITY,
	jmp_list_AssemblyID bigint       NULL,
	jmp_list_EUID       char(32)     NULL,
	jmp_list_CIID       uint         NULL,
	jmp_list_jmp_MSG_ID bigint       NULL,
	jmp_list_afg_MSG_ID bigint       NULL,
    CONSTRAINT fk_JMP_LIST_ASSEMBLY FOREIGN KEY (jmp_list_AssemblyID) REFERENCES dbo.Assembly (ID)
)
LOCK DATAPAGES
go

IF OBJECT_ID('dbo.JMP_LIST') IS NOT NULL
    ALTER TABLE dbo.JMP_LIST PARTITION 1
go

/* Add permissions for table... */
IF OBJECT_ID('dbo.JMP_LIST') IS NOT NULL
BEGIN
    GRANT ALL,UPDATE STATISTICS ON dbo.JMP_LIST TO public
END
go

/* Bind rules & defaults to columns... */
/* End of description of table dbo.JMP_LIST */


/* Start of description of table dbo.MDI */

setuser 'dbo'
go

IF OBJECT_ID('dbo.MDI') IS NOT NULL
BEGIN
    DROP TABLE dbo.MDI
END
go

CREATE TABLE dbo.MDI (
	mdi_MSG_ID     bigint   IDENTITY,
	mdi_AssemblyID bigint       NULL,
	mdi_EUID       char(32)     NULL,
	mdi_CIID       uint         NULL,
	mdi_mea        float(16)     NULL,
	mdi_std        float(16)     NULL,
	mdi_min        int          NULL,
	mdi_max        int          NULL,
    CONSTRAINT fk_MDI_Assembly FOREIGN KEY (mdi_AssemblyID) REFERENCES dbo.Assembly (ID)
)
LOCK DATAPAGES
go

IF OBJECT_ID('dbo.MDI') IS NOT NULL
    ALTER TABLE dbo.MDI PARTITION 1
go

/* Add permissions for table... */
IF OBJECT_ID('dbo.MDI') IS NOT NULL
BEGIN
    GRANT ALL,UPDATE STATISTICS ON dbo.MDI TO public
END
go

/* Bind rules & defaults to columns... */
/* End of description of table dbo.MDI */


/* Start of description of table dbo.UTG */

setuser 'dbo'
go

IF OBJECT_ID('dbo.UTG') IS NOT NULL
BEGIN
    DROP TABLE dbo.UTG
END
go

CREATE TABLE dbo.UTG (
	utg_MSG_ID     bigint        IDENTITY,
	utg_AssemblyID bigint            NULL,
	utg_EUID       char(32)          NULL,
	utg_CIID       uint              NULL,
	utg_src        varchar(255)      NULL,
	utg_mhp        float(16)         NULL,
	utg_cov        float(16)         NULL,
	utg_sta        char(1)           NULL,
	utg_abp        int               NULL,
	utg_bbp        int               NULL,
	utg_len        int               NULL,
	utg_cns        varchar(1000)     NULL,
	utg_qlt        varchar(1000)     NULL,
	utg_for        bit           NOT NULL,
	utg_nfr        int               NULL,
    CONSTRAINT fk_UTG_Assembly FOREIGN KEY (utg_AssemblyID) REFERENCES dbo.Assembly (ID)
)
LOCK DATAPAGES
go

IF OBJECT_ID('dbo.UTG') IS NOT NULL
    ALTER TABLE dbo.UTG PARTITION 2
go

IF EXISTS(SELECT 1 FROM sysindexes
           WHERE name = 'pk_UTG'
             AND id   = OBJECT_ID('dbo.UTG'))
BEGIN
    DROP INDEX UTG.pk_UTG
END
go

IF OBJECT_ID('dbo.UTG') IS NOT NULL
BEGIN
    CREATE UNIQUE NONCLUSTERED INDEX pk_UTG
    ON UTG (utg_MSG_ID)
END
go


/* Add permissions for table... */
IF OBJECT_ID('dbo.UTG') IS NOT NULL
BEGIN
    GRANT ALL,UPDATE STATISTICS ON dbo.UTG TO public
END
go

/* Bind rules & defaults to columns... */
/* End of description of table dbo.UTG */


/* Start of description of table dbo.MPS */

setuser 'dbo'
go

IF OBJECT_ID('dbo.MPS') IS NOT NULL
BEGIN
    DROP TABLE dbo.MPS
END
go

CREATE TABLE dbo.MPS (
	mps_AssemblyID bigint            NULL,
	mps_utg_MSG_ID bigint            NULL,
	mps_afg_MSG_ID bigint            NULL,
	mps_type       char(1)           NULL,
	mps_src        varchar(255)      NULL,
	mps_pos1       int               NULL,
	mps_pos2       int               NULL,
	mps_del        varchar(1000)     NULL,
    CONSTRAINT fk_MPS_AFG FOREIGN KEY (mps_afg_MSG_ID) REFERENCES dbo.AFG (afg_MSG_ID),
    CONSTRAINT fk_MPS_UTG FOREIGN KEY (mps_utg_MSG_ID) REFERENCES dbo.UTG (utg_MSG_ID)
)
LOCK DATAPAGES
go

IF OBJECT_ID('dbo.MPS') IS NOT NULL
    ALTER TABLE dbo.MPS PARTITION 1
go

/* Add permissions for table... */
IF OBJECT_ID('dbo.MPS') IS NOT NULL
BEGIN
    GRANT ALL,UPDATE STATISTICS ON dbo.MPS TO public
END
go

/* Bind rules & defaults to columns... */
/* End of description of table dbo.MPS */


/* Start of description of table dbo.MessageTypes */

setuser 'dbo'
go

IF OBJECT_ID('dbo.MessageTypes') IS NOT NULL
BEGIN
    DROP TABLE dbo.MessageTypes
END
go

CREATE TABLE dbo.MessageTypes (
	MessageTypeID char(3)           NULL,
	ShortDesc     varchar(50)       NULL,
	LongDesc      varchar(1000)     NULL
)
LOCK DATAPAGES
go

IF OBJECT_ID('dbo.MessageTypes') IS NOT NULL
    ALTER TABLE dbo.MessageTypes PARTITION 1
go

/* Add permissions for table... */
IF OBJECT_ID('dbo.MessageTypes') IS NOT NULL
BEGIN
    GRANT ALL,UPDATE STATISTICS ON dbo.MessageTypes TO public
END
go

/* Bind rules & defaults to columns... */
/* End of description of table dbo.MessageTypes */


/* Start of description of table dbo.SCF */

setuser 'dbo'
go

IF OBJECT_ID('dbo.SCF') IS NOT NULL
BEGIN
    DROP TABLE dbo.SCF
END
go

CREATE TABLE dbo.SCF (
	scf_MSG_ID     bigint   IDENTITY,
	scf_AssemblyID bigint       NULL,
	scf_EUID       char(32)     NULL,
	scf_CIID       uint         NULL,
	scf_noc        int          NULL
)
LOCK DATAPAGES
go

IF OBJECT_ID('dbo.SCF') IS NOT NULL
    ALTER TABLE dbo.SCF PARTITION 1
go

/* Add permissions for table... */
IF OBJECT_ID('dbo.SCF') IS NOT NULL
BEGIN
    GRANT ALL,UPDATE STATISTICS ON dbo.SCF TO public
END
go

/* Bind rules & defaults to columns... */
/* End of description of table dbo.SCF */


/* Start of description of table dbo.ULK */

setuser 'dbo'
go

IF OBJECT_ID('dbo.ULK') IS NOT NULL
BEGIN
    DROP TABLE dbo.ULK
END
go

CREATE TABLE dbo.ULK (
	ulk_MSG_ID     bigint   IDENTITY,
	ulk_AssemblyID bigint       NULL,
	ulk_EUID       char(32)     NULL,
	ulk_CIID       uint         NULL,
	ulk_ori        char(1)      NULL,
	ulk_ovt        char(1)      NULL,
	ulk_ipc        bit      NOT NULL,
	ulk_mea        float(16)     NULL,
	ulk_std        float(16)     NULL,
	ulk_num        int          NULL,
	ulk_sta        char(1)      NULL
)
LOCK DATAPAGES
go

IF OBJECT_ID('dbo.ULK') IS NOT NULL
    ALTER TABLE dbo.ULK PARTITION 1
go

/* Add permissions for table... */
IF OBJECT_ID('dbo.ULK') IS NOT NULL
BEGIN
    GRANT ALL,UPDATE STATISTICS ON dbo.ULK TO public
END
go

/* Bind rules & defaults to columns... */
/* End of description of table dbo.ULK */


/* Start of description of table dbo.ULK_LIST */

setuser 'dbo'
go

IF OBJECT_ID('dbo.ULK_LIST') IS NOT NULL
BEGIN
    DROP TABLE dbo.ULK_LIST
END
go

CREATE TABLE dbo.ULK_LIST (
	ulk_list_AssemblyID bigint     NULL,
	ulk_list_utg_MSG_ID bigint     NULL,
	ulk_list_ulk_MSG_ID bigint     NULL
)
LOCK DATAPAGES
go

IF OBJECT_ID('dbo.ULK_LIST') IS NOT NULL
    ALTER TABLE dbo.ULK_LIST PARTITION 1
go

/* Add permissions for table... */
IF OBJECT_ID('dbo.ULK_LIST') IS NOT NULL
BEGIN
    GRANT ALL,UPDATE STATISTICS ON dbo.ULK_LIST TO public
END
go

/* Bind rules & defaults to columns... */
/* End of description of table dbo.ULK_LIST */


/* Start of description of table dbo.UPS */

setuser 'dbo'
go

IF OBJECT_ID('dbo.UPS') IS NOT NULL
BEGIN
    DROP TABLE dbo.UPS
END
go

CREATE TABLE dbo.UPS (
	ups_MSG_ID     bigint        IDENTITY,
	ups_AssemblyID bigint            NULL,
	ups_EUID       char(32)          NULL,
	ups_CIID       uint              NULL,
	ups_cco_MSG_ID bigint            NULL,
	ups_utg_MSG_ID bigint            NULL,
	ups_type       char(1)           NULL,
	ups_pos1       int               NULL,
	ups_pos2       int               NULL,
	ups_del        varchar(1000)     NULL
)
LOCK DATAPAGES
go

IF OBJECT_ID('dbo.UPS') IS NOT NULL
    ALTER TABLE dbo.UPS PARTITION 1
go

/* Add permissions for table... */
IF OBJECT_ID('dbo.UPS') IS NOT NULL
BEGIN
    GRANT ALL,UPDATE STATISTICS ON dbo.UPS TO public
END
go

/* Bind rules & defaults to columns... */
/* End of description of table dbo.UPS */


/* Start of description of table dbo.VAR */

setuser 'dbo'
go

IF OBJECT_ID('dbo.VAR') IS NOT NULL
BEGIN
    DROP TABLE dbo.VAR
END
go

CREATE TABLE dbo.VAR (
	var_MSG_ID     bigint   IDENTITY,
	var_AssemblyID bigint       NULL,
	var_EUID       char(32)     NULL,
	var_CIID       uint         NULL,
	var_cco_MSG_ID bigint       NULL,
	var_pos1       int          NULL,
	var_pos2       int          NULL,
	var_nrd        int          NULL,
	var_nca        int          NULL,
	var_anc        int          NULL,
	var_len        int          NULL,
	var_vid        bigint       NULL,
	var_pid        bigint       NULL
)
LOCK DATAPAGES
go

IF OBJECT_ID('dbo.VAR') IS NOT NULL
    ALTER TABLE dbo.VAR PARTITION 1
go

/* Add permissions for table... */
IF OBJECT_ID('dbo.VAR') IS NOT NULL
BEGIN
    GRANT ALL,UPDATE STATISTICS ON dbo.VAR TO public
END
go

/* Bind rules & defaults to columns... */
/* End of description of table dbo.VAR */


/* Start of description of table dbo.VAR_AFG */

setuser 'dbo'
go

IF OBJECT_ID('dbo.VAR_AFG') IS NOT NULL
BEGIN
    DROP TABLE dbo.VAR_AFG
END
go

CREATE TABLE dbo.VAR_AFG (
	var_afg_MSG_ID     bigint   IDENTITY,
	var_afg_AssemblyID bigint       NULL,
	var_afg_EUID       char(32)     NULL,
	var_afg_CIID       uint         NULL,
	var_afg_var_MSG_ID bigint       NULL,
	var_afg_afg_MSG_ID bigint       NULL
)
LOCK DATAPAGES
go

IF OBJECT_ID('dbo.VAR_AFG') IS NOT NULL
    ALTER TABLE dbo.VAR_AFG PARTITION 1
go

/* Add permissions for table... */
IF OBJECT_ID('dbo.VAR_AFG') IS NOT NULL
BEGIN
    GRANT ALL,UPDATE STATISTICS ON dbo.VAR_AFG TO public
END
go

/* Bind rules & defaults to columns... */
/* End of description of table dbo.VAR_AFG */


/* Start of description of table dbo.VAR_ALLELE */

setuser 'dbo'
go

IF OBJECT_ID('dbo.VAR_ALLELE') IS NOT NULL
BEGIN
    DROP TABLE dbo.VAR_ALLELE
END
go

CREATE TABLE dbo.VAR_ALLELE (
	var_allele_MSG_ID     bigint        IDENTITY,
	var_allele_AssemblyID bigint            NULL,
	var_allele_EUID       char(32)          NULL,
	var_allele_CIID       uint              NULL,
	var_allele_var_MSG_ID bigint            NULL,
	var_allele_nra        int               NULL,
	var_allele_wgt        int               NULL,
	var_ellele_seq        varchar(1000)     NULL
)
LOCK DATAPAGES
go

IF OBJECT_ID('dbo.VAR_ALLELE') IS NOT NULL
    ALTER TABLE dbo.VAR_ALLELE PARTITION 1
go

/* Add permissions for table... */
IF OBJECT_ID('dbo.VAR_ALLELE') IS NOT NULL
BEGIN
    GRANT ALL,UPDATE STATISTICS ON dbo.VAR_ALLELE TO public
END
go

/* Bind rules & defaults to columns... */
/* End of description of table dbo.VAR_ALLELE */


/* Now create the key definitions ...*/


setuser 'dbo'
go

/* Views... */

/* View sysquerymetrics, owner dbo */

IF OBJECT_ID('dbo.sysquerymetrics') IS NOT NULL
BEGIN
    setuser 'dbo'
    DROP VIEW dbo.sysquerymetrics
go

setuser 'dbo'
go
create view sysquerymetrics (uid, gid, hashkey, id, sequence, exec_min, exec_max, exec_avg, elap_min, elap_max, elap_avg, lio_min, lio_max, lio_avg, pio_min, pio_max, pio_avg, cnt, abort_cnt, qtext) as select  a.uid, -a.gid, a.hashkey, a.id, a.sequence, convert(int, substring(b.text, charindex('e1', b.text) + 3, charindex('e2', b.text) - charindex('e1', b.text) - 4)), convert(int, substring(b.text, charindex('e2', b.text) + 3, charindex('e3', b.text) - charindex('e2', b.text) - 4)), convert(int, substring(b.text, charindex('e3', b.text) + 3, charindex('t1', b.text) - charindex('e3', b.text) - 4)), convert(int, substring(b.text, charindex('t1', b.text) + 3, charindex('t2', b.text) - charindex('t1', b.text) - 4)), convert(int, substring(b.text, charindex('t2', b.text) + 3, charindex('t3', b.text) - charindex('t2', b.text) - 4)), convert(int, substring(b.text, charindex('t3', b.text) + 3, charindex('l1', b.text) - charindex('t3', b.text) - 4)), convert(int, substring(b.text, charindex('l1', b.text) + 3, charindex('l2', b.text) - charindex('l1', b.text) - 4)), convert(int, substring(b.text, charindex('l2', b.text) + 3, charindex('l3', b.text) - charindex('l2', b.text) - 4)), convert(int, substring(b.text, charindex('l3', b.text) + 3, charindex('p1', b.text) - charindex('l3', b.text) - 4)), convert(int, substring(b.text, charindex('p1', b.text) + 3, charindex('p2', b.text) - charindex('p1', b.text) - 4)), convert(int, substring(b.text, charindex('p2', b.text) + 3, charindex('p3', b.text) - charindex('p2', b.text) - 4)), convert(int, substring(b.text, charindex('p3', b.text) + 3, charindex('c', b.text) - charindex('p3', b.text) - 4)), convert(int, substring(b.text, charindex('c', b.text) + 2, charindex('ac', b.text) - charindex('c', b.text) - 3)), convert(int, substring(b.text, charindex('ac', b.text) + 3, char_length(b.text) - charindex('ac', b.text) - 2)), a.text from sysqueryplans a, sysqueryplans b where (a.type = 10) and (b.type =1000) and (a.id = b.id) and a.uid = b.uid and a.gid = b.gid
go


/* Procedures... */

/* No procedures found. */

/* Triggers... */

/* No triggers found. */
