CREATE TABLE tbl_sitebase (
	sbase_code				int auto_increment,
    sbase_name				text not null,
    sbase_url				text not null,
    sbase_sslurl			text not null,
    sbase_adminemail		text not null,
	sbase_keywords			text,
	sbase_description		text,
    sbase_analyticstags		text,
	sbase_urltype			smallint default 0,
	sbase_editor			smallint default 1,
	sbase_cache			smallint default 0,
	primary key (sbase_code)
);
CREATE TABLE tbl_user (
    usr_code				int auto_increment,
    usr_id	                text not null,
    usr_passwd				text not null,
    usr_status				smallint default 1,
    usr_kanri				smallint default 0,
    usr_sei               	varchar(50),
    usr_mei               	varchar(50),
    usr_sei_kana          	varchar(50),
    usr_mei_kana          	varchar(50),
	usr_section				text,
	usr_tel					text,
    usr_note	           	text,
    usr_mail_hp           	varchar(100),
    usr_mimg_path			text,
    usr_c_date            	datetime,
	usr_u_date            	datetime,
    primary key (usr_code)
);
CREATE TABLE tbl_section_user (
	secusr_sidx_code		integer	NOT NULL,
	secusr_usr_code			integer,
	primary key (secusr_sidx_code, secusr_usr_code)
);
CREATE TABLE tbl_section_idx (
    sidx_code               int auto_increment,
	sidx_extmodule_code	integer,
    sidx_active             smallint default 1,
	sidx_view				smallint default 1,
	sidx_menuflg			smallint default 1,
	sidx_smapflg			smallint default 1,
    sidx_usr_code         	integer,
    sidx_dir                text,
	sidx_ssl				smallint default 0,
    sidx_title              text,
	sidx_tpl_code			integer,
    sidx_css				text,
    sidx_comment_flg        smallint default 0,
	sidx_order             	integer,
    sidx_c_date             datetime,
    sidx_u_date             datetime,
    primary key (sidx_code)
)TYPE = InnoDB;
CREATE TABLE tbl_section_idx_tmp (
    sidx_code               integer,
	sidx_extmodule_code	integer,
    sidx_active             smallint default 1,
	sidx_view				smallint default 1,
	sidx_menuflg			smallint default 1,
	sidx_smapflg			smallint default 1,
    sidx_usr_code         	integer,
    sidx_dir                text,
	sidx_ssl				smallint default 0,
    sidx_title              text,
	sidx_tpl_code			integer,
    sidx_css				text,
    sidx_comment_flg        smallint default 0,
	sidx_order             	integer,
    sidx_c_date             datetime,
    sidx_u_date             datetime,
    primary key (sidx_code)
)TYPE = InnoDB;
CREATE TABLE tbl_category (
    cat_code              	int auto_increment,
    cat_active            	smallint default 1,
	cat_extmodule_code	integer,
	cat_view				smallint default 1,
    cat_type				smallint default 1,
	cat_menuflg				smallint default 1,
	cat_smapflg			smallint default 1,
    cat_sidx_code         	integer,
    cat_name	          	text,
    cat_order             	integer,
    cat_dir					text,
    cat_c_date            	datetime,
    cat_u_date            	datetime,
    primary key (cat_code)
)TYPE = InnoDB;
CREATE TABLE tbl_category_tmp (
    cat_code              	integer,
    cat_active            	smallint default 1,
	cat_extmodule_code	integer,
	cat_view				smallint default 1,
    cat_type				smallint default 1,
	cat_menuflg				smallint default 1,
	cat_smapflg			smallint default 1,
    cat_sidx_code         	integer,
    cat_name	          	text,
    cat_order             	integer,
    cat_dir					text,
    cat_c_date            	datetime,
    cat_u_date            	datetime,
    primary key (cat_code)
)TYPE = InnoDB;
CREATE TABLE tbl_page_idx (
    pidx_code               int auto_increment,
    pidx_sidx_code          integer,
    pidx_active             smallint default 1,
	pidx_extmodule_code	integer,
    pidx_view               smallint default 1,
    pidx_cat_code         	integer not null,
	pidx_ptype				smallint default 0,
	pidx_url				text,
	pidx_directurl				text,
    pidx_date               date,
    pidx_edate		    	date,
    pidx_title              text,
    pidx_comment			text,
	pidx_comment_pic		text,
	pidx_keywords			text,
	pidx_description		text,
	pidx_analyticstags		text,
    pidx_comment_flg       smallint default 0,
    pidx_cusr_code         	integer,
	pidx_uusr_code			integer,
	pidx_cnsnt_usr_code		integer,
	pidx_rev				text,
	pidx_note				text,
	pidx_c_date				datetime,
	pidx_u_date				datetime,
    primary key (pidx_code)
)TYPE = InnoDB;
CREATE TABLE tbl_page_idx_tmp (
    pidx_code               integer,
    pidx_sidx_code          integer,
    pidx_active             smallint default 1,
	pidx_extmodule_code	integer,
    pidx_view               smallint default 1,
    pidx_cat_code         	integer not null,
	pidx_ptype				smallint default 0,
	pidx_url				text,
	pidx_directurl				text,
    pidx_date               date,
    pidx_edate		    	date,
    pidx_title              text,
    pidx_comment			text,
	pidx_comment_pic		text,
	pidx_keywords			text,
	pidx_description		text,
	pidx_analyticstags		text,
    pidx_comment_flg       smallint default 0,
    pidx_cusr_code         	integer,
	pidx_uusr_code			integer,
	pidx_cnsnt_usr_code		integer,
	pidx_rev				text,
	pidx_note				text,
	pidx_c_date				datetime,
	pidx_u_date				datetime,
    primary key (pidx_code)
)TYPE = InnoDB;
CREATE TABLE tbl_page_container (
	pagec_code			int auto_increment,
	pagec_pidx_code		integer not null,
	pagec_extmodule_code	integer,
	pagec_type			text not null,
	pagec_order			integer default 0,
	primary key (pagec_code)
)TYPE = InnoDB;
CREATE TABLE tbl_page_container_tmp (
	pagec_code			integer,
	pagec_pidx_code		integer not null,
	pagec_extmodule_code	integer,
	pagec_type			text not null,
	pagec_order			integer default 0,
	primary key (pagec_code)
)TYPE = InnoDB;
CREATE TABLE tbl_page_unit (
	pageu_code			int auto_increment,
	pageu_pidx_code		integer not null,
	pageu_pagec_code	integer not null,
	pageu_column		integer default 0,
	pageu_unit_code		integer not null,
	pageu_extmodule_code	integer,
	pageu_order			integer default 0,
	primary key (pageu_code)
)TYPE = InnoDB;
CREATE TABLE tbl_page_unit_tmp (
	pageu_code			integer,
	pageu_pidx_code		integer not null,
	pageu_pagec_code	integer not null,
	pageu_column		integer default 0,
	pageu_unit_code		integer not null,
	pageu_extmodule_code	integer,
	pageu_order			integer default 0,
	primary key (pageu_code)
)TYPE = InnoDB;
CREATE TABLE tbl_unit (
	unit_code			int auto_increment,
	unit_type			integer not null,
	unit_name			text not null,
	unit_tpl_path		text not null,
	unit_php_path		text,
	unit_active			smallint default 1,
	unit_order			integer default 0,
	unit_cache			smallint default 1,
	unit_extmodule_code	integer,
	unit_extmodule_private	smallint default 0,
	unit_cdate			datetime,
	unit_ver				text,
	primary key (unit_code)
)TYPE = InnoDB;
CREATE TABLE tbl_skin (
	skin_code			int auto_increment,
	skin_name			text not null,
	skin_type			text,
	skin_side			smallint default 0,
	skin_ver			text,
	skin_author			text,
	skin_path			text not null,
	skin_active			smallint default 1,
	skin_use			smallint default 0,
	primary key (skin_code)
)TYPE = InnoDB;
CREATE TABLE tbl_template (
	tpl_code			int auto_increment,
	tpl_skin_code		integer,
	tpl_skin_color		text,
	tpl_name			text,
	tpl_summary			text,
	tpl_pagenavi		smallint default 1,
	tpl_hlogo			text,
	tpl_hcap			text,
	tpl_hbgimg			text,
	tpl_hbanner			text,
	tpl_hbannerurl		text,
	tpl_hbannertrgt		smallint default 0,
	tpl_hsubnavi		text,
	tpl_active			smallint default 1,
	tpl_fcap			text,
	tpl_fsubnavi		text,
	primary key (tpl_code)
)TYPE = InnoDB;
CREATE TABLE tbl_sidebar (
	pageu_code			integer,
	sdbr_tpl_code		integer,
	sdbr_unit_code		integer,
	sdbr_order			integer,
	primary key (pageu_code)
)TYPE = InnoDB;
CREATE TABLE tbl_sitemember (
	smmbr_code			int not null auto_increment,
	smmbr_loginid		text,
	smmbr_loginpwd		text,
	smmbr_status			smallint default 1,
	smmbr_sei			text,
	smmbr_mei			text,
	smmbr_sei_kana		text,
	smmbr_mei_kana		text,
	smmbr_email			text,
	smmbr_email_mobile	text,
	smmbr_zip1			text,
	smmbr_zip2			text,
	smmbr_pref			text,
	smmbr_address1		text,
	smmbr_address2		text,
	smmbr_address3		text,
	smmbr_tel01			text,
	smmbr_tel02			text,
	smmbr_tel03			text,
	smmbr_tel11			text,
	smmbr_tel12			text,
	smmbr_tel13			text,
	smmbr_fax1			text,
	smmbr_fax2			text,
	smmbr_fax3			text,
	smmbr_birthday		date,
	smmbr_sex			smallint,
	smmbr_c_date		datetime,
	smmbr_u_date		datetime,
	primary key (smmbr_code)
)TYPE = InnoDB;
CREATE TABLE tbl_extmodule (
	extmodule_code		int not null auto_increment,
	extmodule_active		smallint default 1,
	extmodule_type		smallint default 1,
	extmodule_admin_path	text,
	extmodule_name		text not null,
	extmodule_summary	text,	
	extmodule_ver		text,	
	extmodule_path		text,	
	extmodule_order		integer,
	extmodule_cdate		datetime,
	primary key (extmodule_code)
)TYPE = InnoDB;
CREATE TABLE tbl_extsection_idx (
	sidx_code			int not null auto_increment,
	sidx_extmodule_code	integer,
	sidx_active			smallint default 1,
	sidx_view				smallint default 1,
	sidx_menuflg			smallint default 1,
	sidx_smapflg			smallint default 1,
	sidx_usr_code         	integer,
	sidx_dir				text,	
	sidx_ssl				smallint default 0,
	sidx_title				text,
	sidx_tpl_code			integer,
	sidx_css				text,
	sidx_comment_flg        smallint default 0,
	sidx_order             	integer,
	sidx_c_date			datetime,
	sidx_u_date			datetime,
	primary key (sidx_code)
)TYPE = InnoDB;
CREATE TABLE tbl_extcategory (
	cat_code				int not null auto_increment,
	cat_extmodule_code	integer,
	cat_active			smallint default 1,
	cat_view				smallint default 1,
	cat_type				smallint default 1,
	cat_menuflg			smallint default 1,
	cat_sidx_code		integer,
	cat_name			text,
	cat_order			integer,
	cat_dir				text,
	cat_c_date			datetime,
	cat_u_date			datetime,
	primary key (cat_code)
)TYPE = InnoDB;
CREATE TABLE tbl_extpage_idx (
	pidx_code			int not null auto_increment,
	pidx_extmodule_code	integer,
	pidx_sidx_code		integer,
	pidx_active			smallint default 1,
	pidx_view			smallint default 1,
	pidx_cat_code		integer not null,
	pidx_ptype			smallint default 0,
	pidx_url				text,
	pidx_directurl	text,
	pidx_date			date,
	pidx_edate			date,
	pidx_title				text,
	pidx_comment		text,
	pidx_comment_pic		text,
	pidx_keywords		text,
	pidx_description		text,
	pidx_analyticstags		text,
	pidx_comment_flg       smallint default 0,
	pidx_cusr_code		integer,
	pidx_uusr_code		integer,
	pidx_cnsnt_usr_code	integer,
	pidx_rev				text,
	pidx_note			text,
	pidx_c_date			datetime,
	pidx_u_date			datetime,
	primary key (pidx_code)
)TYPE = InnoDB;
CREATE TABLE tbl_extpage_container (
	pagec_code			int not null auto_increment,
	pagec_extmodule_code	integer,
	pagec_pidx_code		integer not null,
	pagec_type			text not null,
	pagec_order			integer default 0,
	primary key (pagec_code)
)TYPE = InnoDB;
CREATE TABLE tbl_extpage_unit (
	pageu_code			int not null auto_increment,
	pageu_extmodule_code	integer,
	pageu_pidx_code		integer not null,
	pageu_pagec_code	integer not null,
	pageu_column		integer default 0,
	pageu_unit_code		integer not null,
	pageu_order			integer default 0,
	primary key (pageu_code)
)TYPE = InnoDB;
CREATE TABLE tbl_unitclip (
	pageu_code				integer,
	pageu_unit_code			integer not null,
	pageu_extmodule_code	integer,
	unitclip_name				text,
	unitclip_active			smallint default 1,
	primary key(pageu_code)
)TYPE = InnoDB;