CREATE TABLE WB_BBS_FILE
(
  FILE_ID VARCHAR(12) NOT NULL PRIMARY KEY,
  CREATE_DATE DATETIME NOT NULL,
  FILE_NAME VARCHAR(255) NOT NULL,
  FILE_SIZE NUMERIC(10) NOT NULL,
  FILE_CONTENT IMAGE
);

CREATE TABLE WB_BBS_POST
(
  BBS_ID VARCHAR(12) NOT NULL,
  POST_DATE DATETIME NOT NULL,
  POST_USER VARCHAR(12) NOT NULL,
  POST_ID VARCHAR(12) NOT NULL,
  CONTENT TEXT
);
CREATE INDEX WB_BBS_POST_IDX1 ON WB_BBS_POST (BBS_ID, POST_DATE);
CREATE INDEX WB_BBS_POST_IDX2 ON WB_BBS_POST(POST_USER);

CREATE TABLE WB_BBS_TITLE
(
  BBS_ID VARCHAR(12) NOT NULL PRIMARY KEY,
  TITLE VARCHAR(255) NOT NULL,
  SET_TOP NUMERIC(1) NOT NULL,
  CREATE_DATE DATETIME NOT NULL,
  CREATE_USER VARCHAR(50) NOT NULL,
  REPLY_COUNT NUMERIC(8) NOT NULL,
  VIEW_COUNT NUMERIC(8) NOT NULL,
  POST_DATE DATETIME NOT NULL,
  POST_USER VARCHAR(12) NOT NULL,
  CONTENT TEXT
);
CREATE INDEX WB_BBS_TITLE_IDX1 ON WB_BBS_TITLE(SET_TOP, POST_DATE);
CREATE INDEX WB_BBS_TITLE_IDX2 ON WB_BBS_TITLE(CREATE_USER);
CREATE INDEX WB_BBS_TITLE_IDX3 ON WB_BBS_TITLE(POST_USER);

CREATE TABLE WB_CUST
(
  CUST_ID VARCHAR(12) NOT NULL PRIMARY KEY,
  CUST_NO VARCHAR(5) NOT NULL,
  COMPANY VARCHAR(50),
  ADDR VARCHAR(50),
  COUNTRY VARCHAR(20),
  TAX_RATE NUMERIC(6,2),
  INVOICE_DATE DATETIME,
  REMARK TEXT
);

CREATE TABLE WB_DUAL
(
  DMY NUMERIC(1)
);

CREATE TABLE WB_KEY
(
  KEY_ID VARCHAR(12) NOT NULL PRIMARY KEY,
  KEY_TYPE VARCHAR(50) NOT NULL,
  KEY_NAME VARCHAR(50) NOT NULL,
  KEY_VALUE VARCHAR(200) NOT NULL
);
CREATE INDEX WB_KEY_IDX ON WB_KEY(KEY_TYPE);

CREATE TABLE WB_LOG
(
  LOG_DATE DATETIME NOT NULL,
  USER_NAME VARCHAR(50) NOT NULL,
  IP VARCHAR(50) NOT NULL,
  LOG_TYPE NUMERIC(1) NOT NULL,
  MSG VARCHAR(255) NOT NULL
);
CREATE INDEX WB_LOG_IDX ON WB_LOG(LOG_DATE);

CREATE TABLE WB_META
(
  META_NAME VARCHAR(30) NOT NULL PRIMARY KEY,
  META_TYPE VARCHAR(50) NOT NULL,
  META_CONTENT TEXT NOT NULL,
  ORDER_INDEX NUMERIC(6) NOT NULL
);
CREATE INDEX WB_META_IDX ON WB_META(ORDER_INDEX);

CREATE TABLE WB_MODULE
(
  MODULE_ID VARCHAR(12) NOT NULL PRIMARY KEY,
  PARENT_ID VARCHAR(12) NOT NULL,
  MODULE_CONTENT TEXT,
  DISPLAY_NAME VARCHAR(255),
  DISPLAY_ICON VARCHAR(50),
  IS_HIDDEN NUMERIC(1),
  NEW_WIN NUMERIC(1),
  CREATE_USER VARCHAR(12),
  CREATE_DATE DATETIME,
  LAST_MODIFY_USER VARCHAR(12),
  LAST_MODIFY_DATE DATETIME,
  ORDER_INDEX NUMERIC(8)
);
CREATE INDEX WB_MODULE_IDX ON WB_MODULE(PARENT_ID, ORDER_INDEX);

CREATE TABLE WB_MODULE_HIS
(
  HIS_TITLE VARCHAR(100) NOT NULL,
  MODULE_ID VARCHAR(12) NOT NULL,
  PARENT_ID VARCHAR(12) NOT NULL,
  MODULE_CONTENT TEXT,
  DISPLAY_NAME VARCHAR(255),
  DISPLAY_ICON VARCHAR(50),
  IS_HIDDEN NUMERIC(1),
  NEW_WIN NUMERIC(1),
  CREATE_USER VARCHAR(12),
  CREATE_DATE DATETIME,
  LAST_MODIFY_USER VARCHAR(12),
  LAST_MODIFY_DATE DATETIME,
  ORDER_INDEX NUMERIC(8)
);
CREATE INDEX WB_MODULE_HIS_IDX ON WB_MODULE_HIS(HIS_TITLE);

CREATE TABLE WB_MODULE_ROLE
(
  MODULE_ID VARCHAR(12) NOT NULL,
  ROLE_ID VARCHAR(12) NOT NULL
);
CREATE INDEX WB_MODULE_ROLE_IDX ON WB_MODULE_ROLE(MODULE_ID);

CREATE TABLE WB_RESOURCE
(
  RES_ID VARCHAR(200) NOT NULL PRIMARY KEY,
  RES_CONTENT IMAGE
);

CREATE TABLE WB_ROLE
(
  ROLE_ID VARCHAR(12) NOT NULL PRIMARY KEY,
  PARENT_ID VARCHAR(12) NOT NULL,
  ROLE_NAME VARCHAR(50) NOT NULL
);

CREATE TABLE WB_SALE
(
  RCV_DATE DATETIME NOT NULL,
  TXN_ID VARCHAR(20) NOT NULL,
  PAYER_EMAIL VARCHAR(127),
  MC_GROSS NUMERIC(9,2),
  MC_FEE NUMERIC(9,2),
  MC_CURRENCY VARCHAR(10),
  FIRST_NAME VARCHAR(64),
  LAST_NAME VARCHAR(64),
  PAYMENT_DATE VARCHAR(50),
  ADDRESS_COUNTRY VARCHAR(64),
  ADDRESS_STATE VARCHAR(40),
  ADDRESS_CITY VARCHAR(40),
  ADDRESS_STREET VARCHAR(200),
  ITEM_NAME VARCHAR(127),
  RECEIVER_EMAIL VARCHAR(127),
  REG_CODE VARCHAR(20),
  USER_COUNT NUMERIC(7),
  OPT_SUPPORT NUMERIC(1)
);
CREATE INDEX WB_SALE_IDX1 ON WB_SALE(RCV_DATE);
CREATE INDEX WB_SALE_IDX2 ON WB_SALE(REG_CODE);

CREATE TABLE WB_SYSINFO
(
  RCV_DATE DATETIME NOT NULL,
  SYS_TITLE VARCHAR(200),
  SYS_IP VARCHAR(50), 
  SYS_SN VARCHAR(20), 
  SYS_CTX VARCHAR(200)
);
CREATE INDEX WB_SYSINFO_IDX ON WB_SYSINFO(RCV_DATE);

CREATE TABLE WB_TASK
(
  TASK_ID VARCHAR(12) NOT NULL PRIMARY KEY,
  TASK_NAME VARCHAR(100) NOT NULL,
  INTERVAL_TYPE NUMERIC(1) NOT NULL,
  INTERVAL_EXPRESS VARCHAR(10) NOT NULL,
  CLASS_NAME VARCHAR(255) NOT NULL,
  BEGIN_DATE DATETIME,
  END_DATE DATETIME,
  STATUS NUMERIC(1) NOT NULL,
  REMARK VARCHAR(255)
);

CREATE TABLE WB_USER
(
  USER_ID VARCHAR(12) NOT NULL PRIMARY KEY,
  USER_NAME VARCHAR(50) NOT NULL,
  DISPLAY_NAME VARCHAR(100) NOT NULL,
  PASSWORD VARCHAR(32) NOT NULL,
  STATUS NUMERIC(1) NOT NULL,
  CREATE_DATE DATETIME NOT NULL,
  LOGIN_TIMES NUMERIC(9) NOT NULL,
  EMAIL VARCHAR(100),
  USE_LANG VARCHAR(10),
  LAST_LOGIN DATETIME
);
CREATE UNIQUE INDEX WB_USER_UNQ ON WB_USER(USER_NAME);
CREATE INDEX WB_USER_IDX ON WB_USER(STATUS);

CREATE TABLE WB_USER_ROLE
(
  USER_ID VARCHAR(12) NOT NULL,
  ROLE_ID VARCHAR(12) NOT NULL
);
CREATE INDEX WB_USER_ROLE_IDX ON WB_USER_ROLE(USER_ID);

CREATE TABLE WB_VALUE
(
  VAL_ID VARCHAR(200) NOT NULL PRIMARY KEY,
  VAL_CONTENT VARCHAR(255)
);

CREATE TABLE WB_VAR
(
  VAR_ID VARCHAR(12) NOT NULL PRIMARY KEY,
  PARENT_ID VARCHAR(12) NOT NULL,
  VAR_NAME VARCHAR(50) NOT NULL,
  VAR_VALUE VARCHAR(255),
  IS_VAR NUMERIC(1)
);