
# This is a fix for InnoDB in MySQL >= 4.1.x
# It "suspends judgement" for fkey relationships until are tables are set.
SET FOREIGN_KEY_CHECKS = 0;

#-----------------------------------------------------------------------------
#-- tbluser
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `tbluser`;


CREATE TABLE `tbluser`
(
	`us_id` INTEGER  NOT NULL AUTO_INCREMENT,
	`us_username` VARCHAR(30),
	`us_password` VARCHAR(50),
	`us_firstname` VARCHAR(50)  NOT NULL,
	`us_lastname` VARCHAR(50)  NOT NULL,
	`us_sex` TINYINT default 0,
	`us_email` VARCHAR(100)  NOT NULL,
	`us_phone` VARCHAR(50),
	`us_aclgroup` INTEGER,
	`us_school` VARCHAR(100),
	`us_province` VARCHAR(50),
	`us_lastvisited` DATETIME,
	`us_registerdate` DATETIME,
	`us_rating` INTEGER default 0 NOT NULL,
	`us_download` INTEGER default 0,
	`us_avatar` VARCHAR(255),
	`us_status` INTEGER default null,
	`us_key` INTEGER default null,
	`us_company` INTEGER default 0,
	`us_score` INTEGER default 0,
	`us_pointplus` INTEGER default 5,
	`us_checked` TINYINT default 0,
	`us_checkinfo` INTEGER,
	`us_idmd5` VARCHAR(32),
	`us_homepage` VARCHAR(255),
	`us_money` INTEGER default 0,
	PRIMARY KEY (`us_id`)
)Type=MyISAM;

#-----------------------------------------------------------------------------
#-- tblspacecategory
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `tblspacecategory`;


CREATE TABLE `tblspacecategory`
(
	`cat_id` INTEGER  NOT NULL AUTO_INCREMENT,
	`cat_name` VARCHAR(255)  NOT NULL,
	`cat_parent` INTEGER  NOT NULL,
	`cat_user` INTEGER  NOT NULL,
	`cat_date` DATETIME  NOT NULL,
	PRIMARY KEY (`cat_id`)
)Type=MyISAM;

#-----------------------------------------------------------------------------
#-- tblspaceresource
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `tblspaceresource`;


CREATE TABLE `tblspaceresource`
(
	`res_id` INTEGER  NOT NULL AUTO_INCREMENT,
	`res_filename` VARCHAR(255)  NOT NULL,
	`res_filesize` INTEGER,
	`res_filecrc` INTEGER,
	PRIMARY KEY (`res_id`)
)Type=MyISAM;

#-----------------------------------------------------------------------------
#-- tblspacefile
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `tblspacefile`;


CREATE TABLE `tblspacefile`
(
	`file_id` INTEGER  NOT NULL AUTO_INCREMENT,
	`file_resource` INTEGER  NOT NULL,
	`file_category` INTEGER  NOT NULL,
	`file_user` INTEGER  NOT NULL,
	`file_name` VARCHAR(255),
	`file_type` VARCHAR(15),
	`file_date` DATETIME  NOT NULL,
	PRIMARY KEY (`file_id`),
	INDEX `tblspacefile_FI_1` (`file_resource`),
	CONSTRAINT `tblspacefile_FK_1`
		FOREIGN KEY (`file_resource`)
		REFERENCES `tblspaceresource` (`res_id`)
)Type=MyISAM;

# This restores the fkey checks, after having unset them earlier
SET FOREIGN_KEY_CHECKS = 1;
