/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\MDL_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_DM_DICTTABLEREF') 
 CREATE TABLE T_DM_DICTTABLEREF (
FTABLENAME VARCHAR(50) DEFAULT ' ' NOT NULL,
FREFTABLENAME VARCHAR(50) DEFAULT ' ' NOT NULL,
FREFSIGN CHAR(1) DEFAULT '2' NOT NULL,
FREFCARDINALITY CHAR(1) DEFAULT '1' NOT NULL,
FCOLUMNNAME VARCHAR(50) DEFAULT ' ' NOT NULL,
FREFCOLUMNNAME VARCHAR(50) DEFAULT ' ' NOT NULL,
FTIMESTAMP BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_DM_DICTCOLUMN') 
 CREATE TABLE T_DM_DICTCOLUMN (
FTABLENAME VARCHAR(50) DEFAULT ' ' NOT NULL,
FCOLUMNNAME VARCHAR(50) DEFAULT ' ' NOT NULL,
FDATATYPE VARCHAR(20) DEFAULT ' ' NOT NULL,
FLENGTH SMALLINT DEFAULT 0 NOT NULL,
FPRECISION SMALLINT DEFAULT 0 NOT NULL,
FSCOLE SMALLINT DEFAULT 0 NOT NULL,
FDEFAULT NVARCHAR(100) DEFAULT ' ' NOT NULL,
FALLOWNULL CHAR(1) DEFAULT '1' NOT NULL,
FISCOMPUTED CHAR(1) DEFAULT '0' NOT NULL,
FCOMMENT NVARCHAR(200) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(500),
FCREATEDATE DATETIME DEFAULT GETDATE() NOT NULL,
FTIMESTAMP BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_DM_DICTINDEX') 
 CREATE TABLE T_DM_DICTINDEX (
FTABLENAME VARCHAR(50) DEFAULT ' ' NOT NULL,
FINDEXNAME VARCHAR(50) DEFAULT ' ' NOT NULL,
FISCLUSTER CHAR(1) DEFAULT '0' NOT NULL,
FISUNIQUE CHAR(1) DEFAULT '0' NOT NULL,
FTYPE CHAR(1) DEFAULT '0' NOT NULL,
FCOLUMNS VARCHAR(2000) DEFAULT ' ' NOT NULL,
FTIMESTAMP BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_DM_DICTTABLE') 
 CREATE TABLE T_DM_DICTTABLE (
FTABLENAME VARCHAR(50) DEFAULT ' ' NOT NULL,
FAPPNUMBER VARCHAR(36) DEFAULT ' ' NOT NULL,
FMODELNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FCOMMENT NVARCHAR(200) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(500),
FCREATEDATE DATETIME DEFAULT GETDATE() NOT NULL,
FVERSION BIGINT DEFAULT 0 NOT NULL,
FTIMESTAMP BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_DM_PDMDIAGRAM_D') 
 CREATE TABLE T_DM_PDMDIAGRAM_D (
FID VARCHAR(100) DEFAULT ' ' NOT NULL,
FNUMBER VARCHAR(30) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMASTERID VARCHAR(100) DEFAULT ' ' NOT NULL,
FTYPE CHAR(1) DEFAULT '0' NOT NULL,
FPRODUCT VARCHAR(20) DEFAULT ' ' NOT NULL,
FBIZAPPID VARCHAR(36) DEFAULT ' ' NOT NULL,
FISV VARCHAR(8) DEFAULT ' ' NOT NULL,
FINDEX INT DEFAULT 0 NOT NULL,
FDATA NCLOB,
FVERSION BIGINT DEFAULT 0 NOT NULL,
FPRODUCTVER VARCHAR(20) DEFAULT ' ' NOT NULL,
FITERATION INT DEFAULT 0 NOT NULL,
FCREATOR BIGINT DEFAULT 0 NOT NULL,
FCREATEDATE DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFIER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMODIFYDATE DATETIME,
FTIMESTAMP BIGINT DEFAULT 0 NOT NULL,
FISMERGE CHAR(1) DEFAULT '0' NOT NULL,
FDESCRIPTION NVARCHAR(200),
FIP VARCHAR(30) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_DM_PDMDIAGRAM_M') 
 CREATE TABLE T_DM_PDMDIAGRAM_M (
FID VARCHAR(100) DEFAULT ' ' NOT NULL,
FNUMBER VARCHAR(30) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMASTERID VARCHAR(100) DEFAULT ' ' NOT NULL,
FTYPE CHAR(1) DEFAULT '0' NOT NULL,
FPRODUCT VARCHAR(20) DEFAULT ' ' NOT NULL,
FBIZAPPID VARCHAR(36) DEFAULT ' ' NOT NULL,
FISV VARCHAR(8) DEFAULT ' ' NOT NULL,
FINDEX INT DEFAULT 0 NOT NULL,
FDATA NCLOB,
FVERSION BIGINT DEFAULT 0 NOT NULL,
FPRODUCTVER VARCHAR(20) DEFAULT ' ' NOT NULL,
FITERATION INT DEFAULT 0 NOT NULL,
FCREATOR BIGINT DEFAULT 0 NOT NULL,
FCREATEDATE DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFIER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMODIFYDATE DATETIME,
FTIMESTAMP BIGINT DEFAULT 0 NOT NULL,
FDESCRIPTION NVARCHAR(200)
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_DM_PDMMODEL_D') 
 CREATE TABLE T_DM_PDMMODEL_D (
FID VARCHAR(100) DEFAULT ' ' NOT NULL,
FNUMBER VARCHAR(30) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMASTERID VARCHAR(100) DEFAULT ' ' NOT NULL,
FTYPE CHAR(1) DEFAULT '0' NOT NULL,
FPRODUCT VARCHAR(20) DEFAULT ' ' NOT NULL,
FBIZAPPID VARCHAR(36) DEFAULT ' ' NOT NULL,
FISV VARCHAR(8) DEFAULT ' ' NOT NULL,
FINDEX INT DEFAULT 0 NOT NULL,
FDATA NCLOB,
FVERSION BIGINT DEFAULT 0 NOT NULL,
FPRODUCTVER VARCHAR(20) DEFAULT ' ' NOT NULL,
FITERATION INT DEFAULT 0 NOT NULL,
FCREATOR BIGINT DEFAULT 0 NOT NULL,
FCREATEDATE DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFIER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMODIFYDATE DATETIME,
FTIMESTAMP BIGINT DEFAULT 0 NOT NULL,
FISMERGE CHAR(1) DEFAULT '0' NOT NULL,
FDESCRIPTION NVARCHAR(200),
FIP VARCHAR(30) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_DM_PDMMODEL_M') 
 CREATE TABLE T_DM_PDMMODEL_M (
FID VARCHAR(100) DEFAULT ' ' NOT NULL,
FNUMBER VARCHAR(30) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMASTERID VARCHAR(100) DEFAULT ' ' NOT NULL,
FTYPE CHAR(1) DEFAULT '0' NOT NULL,
FPRODUCT VARCHAR(20) DEFAULT ' ' NOT NULL,
FBIZAPPID VARCHAR(36) DEFAULT ' ' NOT NULL,
FISV VARCHAR(8) DEFAULT ' ' NOT NULL,
FINDEX INT DEFAULT 0 NOT NULL,
FDATA NCLOB,
FVERSION BIGINT DEFAULT 0 NOT NULL,
FPRODUCTVER VARCHAR(20) DEFAULT ' ' NOT NULL,
FITERATION INT DEFAULT 0 NOT NULL,
FCREATOR BIGINT DEFAULT 0 NOT NULL,
FCREATEDATE DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFIER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMODIFYDATE DATETIME,
FTIMESTAMP BIGINT DEFAULT 0 NOT NULL,
FDESCRIPTION NVARCHAR(200)
);



/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\MDL_table.sql **/
