 /**
  * Database script for onet forums 4.0
  * ORACLE script
  * Creation Date:2006/4/25
  */
CREATE TABLE onetUser (
	key_id INTEGER NOT NULL ,
	username VARCHAR2 (50) UNIQUE NOT NULL ,
	passwordEncrypted VARCHAR2 (50) NOT NULL ,
	email VARCHAR2 (255) NOT NULL ,
	emailVisible INTEGER NOT NULL ,
	activeValue INTEGER NOT NULL ,
	reminderQuestion VARCHAR2 (255),
	reminderAnswer VARCHAR2 (2000) ,
	creationTime INTEGER NOT NULL ,
	modificationTime INTEGER NOT NULL,
	CONSTRAINT onet_pk_us PRIMARY KEY(key_id)
);

CREATE TABLE onetUserProp (
	objectID INTEGER NOT NULL ,
	propName VARCHAR2 (150) NOT NULL ,
	propValue VARCHAR2 (2000) NOT NULL,
	CONSTRAINT onet_pk_uspr PRIMARY KEY(objectID,propName)
);

CREATE TABLE onetGroup (
	key_id INTEGER NOT NULL ,
	groupName VARCHAR2 (150) UNIQUE NOT NULL ,
	description VARCHAR2 (2000) ,
	creationTime INTEGER NOT NULL ,
	modificationTime INTEGER NOT NULL,
	CONSTRAINT onet_pk_gr PRIMARY KEY(key_id)
);

CREATE TABLE onetGroupProp (
	objectID INTEGER NOT NULL ,
	propName VARCHAR2 (150) NOT NULL ,
	propValue VARCHAR2 (2000) NOT NULL,
	CONSTRAINT onet_pk_grpr PRIMARY KEY(objectID,propName)
);

CREATE TABLE onetUserGroup (
	userID INTEGER NOT NULL ,
	groupID INTEGER NOT NULL,
	CONSTRAINT onet_pk_usgr PRIMARY KEY(userID,groupID)
);
ALTER TABLE onetUserGroup ADD CONSTRAINT onet_fk_ug_gr FOREIGN KEY(groupID) REFERENCES onetGroup (key_id);
ALTER TABLE onetUserGroup ADD CONSTRAINT onet_fk_ug_us FOREIGN KEY(userID) REFERENCES onetUser(key_id);

CREATE TABLE onetUserPerm (
	key_id INTEGER NOT NULL ,
	objectID INTEGER NOT NULL ,
	objectType INTEGER NOT NULL ,
	userID INTEGER NOT NULL ,
	permission INTEGER NOT NULL,
	CONSTRAINT onet_pk_uspe PRIMARY KEY(key_id)
);
CREATE UNIQUE INDEX onet_uk_uspe ON onetUserPerm (objectType,objectID,userID,permission);

CREATE TABLE onetGroupPerm (
	key_id INTEGER NOT NULL ,
	objectID INTEGER NOT NULL ,
	objectType INTEGER NOT NULL ,
	groupID INTEGER NOT NULL ,
	permission INTEGER NOT NULL,
	CONSTRAINT onet_pk_grpe PRIMARY KEY(key_id)
);
CREATE UNIQUE INDEX onet_uk_grpe ON onetGroupPerm(objectID,objectType,groupID,permission);

CREATE TABLE onetZone (
	key_id INTEGER NOT NULL ,
	parentID INTEGER NOT NULL ,
	zoneName VARCHAR2 (255) NOT NULL ,
	description VARCHAR2 (2000),
	indexValue INTEGER NOT NULL,
	modificationTime INTEGER NOT NULL ,
	creationTime INTEGER NOT NULL ,
	CONSTRAINT onet_pk_zo PRIMARY KEY(key_id)
);
CREATE TABLE onetZoneProp (
	objectID INTEGER NOT NULL ,
	propName VARCHAR2 (150) NOT NULL ,
	propValue VARCHAR2 (2000) NOT NULL,
	CONSTRAINT onet_pk_zopr PRIMARY KEY(objectID,propName)
);
ALTER TABLE onetZoneProp ADD CONSTRAINT onet_fk_zp_zo FOREIGN KEY(objectID) REFERENCES onetZone(key_id);

CREATE TABLE onetForum (
	key_id INTEGER NOT NULL ,
	zoneID INTEGER NOT NULL ,
	forumName VARCHAR2 (255) NOT NULL ,
	description VARCHAR2 (2000) ,
	indexValue INTEGER NOT NULL,
	modificationtime INTEGER NOT NULL ,
	creationTime INTEGER NOT NULL ,
	CONSTRAINT onet_pk_fo PRIMARY KEY(key_id)
);
ALTER TABLE onetForum ADD CONSTRAINT onet_fk_fo_zo FOREIGN KEY(zoneID) REFERENCES onetZone (key_id);

CREATE TABLE onetForumProp (
	objectID INTEGER NOT NULL ,
	propName VARCHAR2 (150) NOT NULL ,
	propValue VARCHAR2 (2000) NOT NULL,
	CONSTRAINT onet_pk_fop PRIMARY KEY(objectID,propName)
);
ALTER TABLE onetForumProp ADD CONSTRAINT onet_fk_fopr_fo FOREIGN KEY(objectID) REFERENCES onetForum (key_id);

CREATE TABLE onetForumThread (
	key_id INTEGER NOT NULL ,
	forumID INTEGER NOT NULL ,
	categoryID INTEGER NOT NULL ,
	rootID INTEGER NOT NULL ,
	userID INTEGER NOT NULL ,
	modValue INTEGER NOT NULL ,
	delValue INTEGER NOT NULL ,
	msgCount INTEGER NOT NULL ,
	viewCount INTEGER NOT NULL ,
	modificationTime INTEGER NOT NULL ,
	creationTime INTEGER NOT NULL,
	CONSTRAINT onet_pk_fot PRIMARY KEY(key_id)
);
ALTER TABLE onetForumThread ADD	CONSTRAINT onet_fk_foth_fo FOREIGN KEY(forumID) REFERENCES onetForum (key_id);

CREATE TABLE onetForumThreadProp (
	objectID INTEGER NOT NULL ,
	propName VARCHAR2 (150) NOT NULL ,
	propValue VARCHAR2 (2000) NOT NULL,
	CONSTRAINT onet_pk_fotp PRIMARY KEY(objectID,propName)
);
ALTER TABLE onetForumThreadProp ADD CONSTRAINT onet_fk_fotp_ft FOREIGN KEY(objectID) REFERENCES onetForumThread (key_id);

CREATE TABLE onetForumMessage (
	key_id INTEGER NOT NULL ,
	parentID INTEGER NOT NULL ,
	threadID INTEGER NOT NULL ,
	forumID INTEGER NOT NULL ,
	userID INTEGER NOT NULL ,
	author VARCHAR2(255) NOT NULL ,
	subject VARCHAR2 (255) NOT NULL ,
	body LONG ,
	modValue INTEGER NOT NULL ,
	delValue INTEGER NOT NULL ,
	viewCount INTEGER NOT NULL ,
	modificationTime INTEGER NOT NULL ,
	creationTime INTEGER NOT NULL,
	CONSTRAINT onet_pk_fom PRIMARY KEY(key_id)
);
ALTER TABLE onetForumMessage ADD CONSTRAINT onet_fk_fome_fo FOREIGN KEY(forumID) REFERENCES onetForum (key_id);
ALTER TABLE onetForumMessage ADD CONSTRAINT onet_fk_fome_foth FOREIGN KEY(threadID) REFERENCES onetForumThread (key_id);

CREATE TABLE onetForumMessageProp (
	objectID INTEGER NOT NULL ,
	propName VARCHAR2 (150) NOT NULL ,
	propValue VARCHAR2 (2000) NOT NULL,
	CONSTRAINT onet_pk_fomp PRIMARY KEY(objectID,propName)
);

CREATE TABLE onetForumThreadExc (
	key_id INTEGER NOT NULL ,
	forumID INTEGER NOT NULL,
	CONSTRAINT onet_pk_fote PRIMARY KEY(key_id)
);
CREATE INDEX onet_ix_fote ON onetForumThreadExc(forumID);
ALTER TABLE onetForumThreadExc ADD CONSTRAINT onet_fk_fte_ft FOREIGN KEY(key_id) REFERENCES onetForumThread (key_id);

CREATE TABLE onetForumThreadTop (
	key_id INTEGER NOT NULL ,
	objectID INTEGER NOT NULL ,
	objectType INTEGER NOT NULL ,
	creationTime INTEGER NOT NULL,
	CONSTRAINT onet_pk_fott PRIMARY KEY(key_id)
);
ALTER TABLE onetForumThreadTop ADD CONSTRAINT onet_fk_fott_ft FOREIGN KEY(key_id) REFERENCES onetForumThread (key_id);

CREATE TABLE onetAttachment (
	key_id INTEGER NOT NULL ,
	objectID INTEGER ,
	objectType INTEGER NOT NULL ,
	fileName VARCHAR2 (255) NOT NULL ,
	fileSize INTEGER NOT NULL ,
	fileSpecs VARCHAR2 (50) ,
	contentType VARCHAR2 (50) NOT NULL ,
	creationTime INTEGER NOT NULL,
	CONSTRAINT onet_pk_at PRIMARY KEY(key_id)
);

CREATE TABLE onetAttachmentProp (
	objectID INTEGER NOT NULL ,
	propName VARCHAR2 (150) NOT NULL ,
	propValue VARCHAR2 (2000) NOT NULL,
	CONSTRAINT onet_pk_atp PRIMARY KEY(objectID,propName)
);

CREATE TABLE onetAttachData (
	attachID INTEGER NOT NULL ,
	attachData BLOB NOT NULL ,
	CONSTRAINT onet_pk_atda PRIMARY KEY(attachID)
);
ALTER TABLE onetAttachData ADD	CONSTRAINT onet_fk_atda_at FOREIGN KEY(attachID) REFERENCES onetAttachment (key_id);

CREATE TABLE onetForumCategory(
    key_id INTEGER NOT NULL,
    forumID INTEGER NOT NULL,
    cateName VARCHAR2 (255) NOT NULL,
    cateDescription VARCHAR2 (255) NOT NULL,
    cateImage VARCHAR2(255) NOT NULL,
    indexValue INTEGER NOT NULL,
    creationTime INTEGER NOT NULL,
    CONSTRAINT onet_pk_foc PRIMARY KEY(key_id)
);
ALTER TABLE onetForumCategory ADD CONSTRAINT onet_fk_fc_fo FOREIGN KEY (forumID) REFERENCES onetforum(key_id);

CREATE TABLE onetForumAuthorized(
    key_id INTEGER NOT NULL,
    forumID INTEGER NOT NULL,
    paidCount INTEGER NOT NULL,
    lastPaidTime INTEGER NOT NULL,
    creationTime INTEGER NOT NULL,
    CONSTRAINT onet_pk_foa PRIMARY KEY(key_id)
);
ALTER TABLE onetForumAuthorized ADD CONSTRAINT onet_fk_fau_fo FOREIGN KEY (forumID) REFERENCES onetforum(key_id);

CREATE TABLE onetAvatar (
	key_id INTEGER NOT NULL ,
	ownerID INTEGER ,
	CONSTRAINT onet_pk_av PRIMARY KEY(key_id)
);

CREATE TABLE onetAvatarProp (
	objectID INTEGER NOT NULL ,
	propName VARCHAR2 (150) NOT NULL ,
	propValue VARCHAR2 (2000) NOT NULL,
	CONSTRAINT onet_pk_avp PRIMARY KEY(objectID,propName)
);

CREATE TABLE onetAvatarUser (
	userID INTEGER NOT NULL ,
	avatarID INTEGER NOT NULL,
	CONSTRAINT onet_pk_avu PRIMARY KEY(userID)
);

CREATE TABLE onetFaction (
	key_id INTEGER NOT NULL ,
	name VARCHAR2 (255) NOT NULL ,
	description VARCHAR2 (2000) ,
	CONSTRAINT onet_pk_fac PRIMARY KEY(key_id)
);

CREATE TABLE onetFactionUser (
	factionID INTEGER NOT NULL ,
	userID INTEGER NOT NULL,
	CONSTRAINT onet_pk_faus PRIMARY KEY(factionID,userID)
);

CREATE TABLE onetFavorite (
	key_id INTEGER UNIQUE NOT NULL ,
	userID INTEGER NOT NULL ,
	objectID INTEGER NOT NULL ,
	objectType INTEGER NOT NULL,
	CONSTRAINT onet_pk_fav PRIMARY KEY(userID,objectID,objectType)
);

CREATE TABLE onetFriend (
	key_id INTEGER UNIQUE NOT NULL ,
	userID INTEGER NOT NULL ,
	memberID INTEGER NOT NULL ,
	groupID INTEGER NOT NULL ,
	creationTime INTEGER NOT NULL,
	CONSTRAINT onet_pk_fr PRIMARY KEY(userID,memberID)
);

CREATE TABLE onetFriendGroup (
	key_id INTEGER NOT NULL ,
	userID INTEGER NOT NULL ,
	name VARCHAR2 (255) NOT NULL,
	CONSTRAINT onet_pk_frg PRIMARY KEY(key_id)
);

CREATE TABLE onetPMessage (
	key_id INTEGER NOT NULL ,
	userID INTEGER NOT NULL ,
	senderID INTEGER NOT NULL ,
	recipientID INTEGER NOT NULL ,
	subject VARCHAR2(50) NOT NULL ,
	body LONG ,
	readValue INTEGER NOT NULL ,
	folderID INTEGER NOT NULL ,
	creationTime INTEGER NOT NULL,
	CONSTRAINT onet_pk_pm PRIMARY KEY(key_id)
);

CREATE TABLE onetPMessageFldr (
	key_id INTEGER NOT NULL ,
	userID INTEGER NOT NULL ,
	name VARCHAR2 (255) NOT NULL,
	CONSTRAINT onet_pk_pmfl PRIMARY KEY(key_id)
);

CREATE TABLE onetPMessageProp (
	objectID INTEGER NOT NULL ,
	propName VARCHAR2 (150) NOT NULL ,
	propValue VARCHAR2 (2000) NOT NULL,
	CONSTRAINT onet_pk_pmpr PRIMARY KEY(objectID,propName)
);

CREATE TABLE onetPoll (
	key_id INTEGER NOT NULL ,
	pollMode INTEGER NOT NULL ,
	lifeTime INTEGER NOT NULL ,
	creationTime INTEGER NOT NULL,
	CONSTRAINT onet_pk_poll PRIMARY KEY(key_id)
);
ALTER TABLE onetPoll ADD CONSTRAINT onet_fk_po_ft FOREIGN KEY(key_id) REFERENCES onetForumThread (key_id);

CREATE TABLE onetPollItem (
	key_id INTEGER NOT NULL ,
	pollID INTEGER NOT NULL ,
	itemName VARCHAR2 (255) NOT NULL ,
	voteCount INTEGER NOT NULL,
	CONSTRAINT onet_pk_poit PRIMARY KEY(key_id)
);
ALTER TABLE onetPollItem ADD CONSTRAINT onet_fk_poit_po FOREIGN KEY(pollID) REFERENCES onetPoll (key_id);

CREATE TABLE onetProperty (
	propName VARCHAR2 (150) NOT NULL ,
	propValue LONG NOT NULL,
	CONSTRAINT onet_pk_pr PRIMARY KEY(propName)
);

CREATE TABLE onetReadTrack (
	userID INTEGER NOT NULL ,
	objectID INTEGER NOT NULL ,
	objectType INTEGER NOT NULL ,
	readTime INTEGER NOT NULL,
	CONSTRAINT onet_pk_retr PRIMARY KEY(userID,objectID,objectType)
);


CREATE TABLE onetSequence (
	key_id INTEGER NOT NULL ,
	currentID INTEGER NOT NULL,
	CONSTRAINT onet_pk_se PRIMARY KEY(key_id)
);



CREATE TABLE onetStatusLevel (
	key_id INTEGER NOT NULL ,
	name VARCHAR2 (150) UNIQUE NOT NULL ,
	description LONG ,
	imagePath VARCHAR2 (255) NOT NULL ,
	minPoints INTEGER ,
	maxPoints INTEGER ,
	groupID INTEGER,
	CONSTRAINT onet_pk_stle PRIMARY KEY(key_id)
);

CREATE TABLE onetStatusLevelProp (
	objectID INTEGER NOT NULL ,
	propName VARCHAR2 (150) NOT NULL ,
	propValue VARCHAR2 (2000) NOT NULL,
	CONSTRAINT onet_pk_stlepr PRIMARY KEY(objectID,propName)
);

CREATE TABLE onetLayout (
	key_id INTEGER NOT NULL ,
	pathId VARCHAR2 (150) NOT NULL ,
	name VARCHAR2 (255) NOT NULL ,
	description VARCHAR2 (2000) ,
	creationtime INTEGER NOT NULL,
	CONSTRAINT onet_pk_lay PRIMARY KEY(key_id)
);

CREATE TABLE onetSkin (
	key_id INTEGER NOT NULL ,
	layoutID INTEGER NOT NULL ,
	pathId VARCHAR2 (150) NOT NULL ,
	name VARCHAR2 (255) NOT NULL ,
	description VARCHAR2 (2000) ,
	creationtime INTEGER NOT NULL,
	CONSTRAINT onet_pk_sk PRIMARY KEY(key_id)
);
CREATE UNIQUE INDEX onet_uk_sk ON onetSkin(pathId,layoutID);
ALTER TABLE onetSkin ADD CONSTRAINT onet_fk_sk_lay FOREIGN KEY(layoutID) REFERENCES onetLayout(key_id);

CREATE TABLE onetSkinProp (
	objectID INTEGER NOT NULL ,
	propName VARCHAR2 (150) NOT NULL ,
	propValue LONG NOT NULL,
	CONSTRAINT onet_pk_skpr PRIMARY KEY(objectID,propName)
);

CREATE TABLE onetStyle (
	key_id INTEGER NOT NULL ,
	skinID INTEGER NOT NULL ,
	filename VARCHAR2 (150) NOT NULL,
	name VARCHAR2 (255) NOT NULL ,
	description VARCHAR2 (2000) ,
	creationTime INTEGER NOT NULL,
	CONSTRAINT onet_pk_st PRIMARY KEY(key_id)
);
ALTER TABLE onetStyle ADD CONSTRAINT onet_fk_st_sk FOREIGN KEY(skinID) REFERENCES onetSkin(key_id);

CREATE TABLE onetStyleProp (
	objectID INTEGER NOT NULL ,
	propName VARCHAR2 (150) NOT NULL ,
	propValue LONG NOT NULL,
	CONSTRAINT onet_pk_stpr PRIMARY KEY(objectID,propName)
);

CREATE TABLE onetTask (
	key_id INTEGER NOT NULL ,
	name VARCHAR2 (255) NOT NULL ,
	receiverType INTEGER NOT NULL ,
	sendType INTEGER NOT NULL ,
	activeType INTEGER NOT NULL ,
	activeValue INTEGER NOT NULL ,
	currentSequence INTEGER NOT NULL ,
	creationTime INTEGER NOT NULL,
	CONSTRAINT onet_pk_ta PRIMARY KEY(key_id)
);

CREATE TABLE onetTaskDetail (
	key_id INTEGER UNIQUE NOT NULL ,
	taskID INTEGER NOT NULL ,
	sequenceValue INTEGER NOT NULL ,
	startTime INTEGER NOT NULL ,
	endTime INTEGER NOT NULL ,
	stopValue INTEGER NOT NULL ,
	lastUserID INTEGER NOT NULL ,
	sentTotal INTEGER NOT NULL,
	CONSTRAINT onet_pk_tade PRIMARY KEY(taskID,sequenceValue)
);

CREATE TABLE onetTaskDetailProp (
	objectID INTEGER NOT NULL ,
	propName VARCHAR2 (150) NOT NULL ,
	propValue LONG NOT NULL,
	CONSTRAINT onet_pk_tadepr PRIMARY KEY(objectID,propName)
);

CREATE TABLE onetTaskProp (
	objectID INTEGER NOT NULL ,
	propName VARCHAR2 (150) NOT NULL ,
	propValue LONG NOT NULL,
	CONSTRAINT onet_pk_tapr PRIMARY KEY(objectID,propName)
);


CREATE TABLE onetVoteTrack (
	key_id INTEGER NOT NULL ,
	objectID INTEGER NOT NULL ,
	objectType INTEGER NOT NULL ,
	userID INTEGER NOT NULL ,
	voteTime INTEGER ,
	CONSTRAINT onet_pk_votr PRIMARY KEY(objectID,objectType,userID)
);

CREATE TABLE onetWatch (
	key_id INTEGER UNIQUE NOT NULL,
	userID INTEGER NOT NULL ,
	objectID INTEGER NOT NULL ,
	objectType INTEGER NOT NULL ,
	watchType INTEGER NOT NULL ,
	scheduled INTEGER NOT NULL ,
	expirable INTEGER NOT NULL,
	CONSTRAINT onet_pk_wa PRIMARY KEY(userID,objectID,objectType)
);

CREATE TABLE onetWatchScheduled (
	key_id INTEGER NOT NULL ,
	intervals INTEGER NOT NULL ,
	prevNotifiedTime INTEGER NOT NULL,
	CONSTRAINT onet_pk_wasc PRIMARY KEY(key_id)
);

CREATE TABLE onetAlliance(
    key_id INTEGER NOT NULL,
    forumName VARCHAR2 (150) NOT NULL,
    description VARCHAR2 (255) NOT NULL,
    forumURL VARCHAR2 (255) NOT NULL,
    logoURL VARCHAR2 (255) NOT NULL,
    showMode INTEGER NOT NULL,
    creationTime INTEGER NOT NULL,
    CONSTRAINT onet_pk_al PRIMARY KEY (key_id)
);

CREATE TABLE onetAnnounce (
	key_id INTEGER NOT NULL ,
	objectID INTEGER NOT NULL ,
	userID INTEGER NOT NULL ,
	objectType INTEGER NOT NULL ,
	annType INTEGER DEFAULT 1,
	subject VARCHAR2 (255)  ,
	body LONG NOT NULL ,
	viewCount INTEGER NOT NULL,
	creationTime INTEGER NOT NULL,
	CONSTRAINT onet_pk_an PRIMARY KEY (key_id)
);

CREATE TABLE onetAnnounceProp (
	objectID INTEGER NOT NULL ,
	propName VARCHAR2 (150) NOT NULL ,
	propValue VARCHAR2 (2000) NOT NULL ,
	CONSTRAINT onet_pk_anp PRIMARY KEY( objectID,	propName)
);

CREATE TABLE onetForumEvent(
    key_id INTEGER NOT NULL,
    forumID INTEGER NOT NULL,
    eventSubject VARCHAR2(255) NOT NULL,
    eventBody LONG NOT NULL,
    eventType INTEGER NOT NULL,
    userID INTEGER NOT NULL,
    fromIP VARCHAR2(50) NOT NULL,
    creationTime INTEGER NOT NULL,
    CONSTRAINT onet_pk_foev PRIMARY KEY (key_id)
);

CREATE TABLE onetPluginProp (
    key_id VARCHAR2 (50) NOT NULL ,
	propName VARCHAR2 (150) NOT NULL ,
	propValue LONG NOT NULL,
	CONSTRAINT onet_pk_plp PRIMARY KEY(key_id,propName)
);
CREATE TABLE onetPointCategory(
    key_id INTEGER NOT NULL,
    forumID INTEGER NOT NULL,
    categoryName VARCHAR2 (255) NOT NULL,
    pointUnit VARCHAR2 (50) NOT NULL,
    settings VARCHAR2 (255) NOT NULL,
    showValue INTEGER NOT NULL,
    tradeValue INTEGER NOT NULL,
    modifyValue INTEGER NOT NULL,
    creationTime INTEGER NOT NULL,
    CONSTRAINT onet_pk_poic PRIMARY KEY(key_id,forumID)
);
CREATE TABLE onetPoints(
    userID INTEGER NOT NULL,
    categoryID INTEGER NOT NULL,
    messageValue INTEGER NOT NULL,
    operationValue INTEGER NOT NULL,
    onlineValue INTEGER NOT NULL,
    loginValue INTEGER NOT NULL,
    CONSTRAINT onet_pk_poin PRIMARY KEY(userID,categoryID)
);

CREATE TABLE onetPointsheet (
	key_id INTEGER NOT NULL ,
	currentTopics INTEGER NOT NULL ,
	removedTopics INTEGER NOT NULL ,
	currentReplies INTEGER NOT NULL ,
	removedReplies INTEGER NOT NULL ,
	excCount INTEGER NOT NULL ,
	loginCount INTEGER NOT NULL ,
	onlineTime INTEGER NOT NULL ,
	lastLogin INTEGER NOT NULL,
	CONSTRAINT onet_pk_pos PRIMARY KEY(key_id)
);
CREATE TABLE onetTrade (
    key_id INTEGER NOT NULL ,
	userID INTEGER NOT NULL ,
	orderNo VARCHAR2 (100) UNIQUE NOT NULL ,
	orderGross  INTEGER NOT NULL ,
	orderType INTEGER NOT NULL ,
	orderStatus INTEGER NOT NULL ,
	creationTime INTEGER NOT NULL ,
	CONSTRAINT onet_pk_tr PRIMARY KEY(key_id)
);

CREATE TABLE onetTradeProp (
	objectID INTEGER NOT NULL ,
	propName VARCHAR2 (150) NOT NULL ,
	propValue LONG NOT NULL,
	CONSTRAINT onet_pk_trp PRIMARY KEY(objectID,propName)
);
ALTER TABLE onetTradeProp ADD CONSTRAINT onet_fk_tp_tr FOREIGN KEY(objectID) REFERENCES onetTrade (key_id);

CREATE TABLE onetSynchronize (
    key_id VARCHAR2 (255) NOT NULL,
	keyName VARCHAR2 (2000) NOT NULL ,
	keyValue LONG NOT NULL ,
	fromIP VARCHAR2 (50) NOT NULL ,
	creationTime INTEGER NOT NULL ,
	CONSTRAINT onet_pk_sy PRIMARY KEY(key_id)
);

CREATE TABLE onetStatusLevelPoints(
    key_id INTEGER NOT NULL,
    points INTEGER NOT NULL,
    CONSTRAINT onet_pk_stlepo PRIMARY KEY(key_id)
);

CREATE TABLE onetAPerm(
    objectID INTEGER NOT NULL,
    objectType INTEGER NOT NULL,
    userID INTEGER NOT NULL,
    userType INTEGER NOT NULL,
    keyName VARCHAR2 (150) NOT NULL,
    keyValue VARCHAR2 (255) NOT NULL,
    CONSTRAINT onet_pk_aper PRIMARY KEY(objectID,objectType,userID,userType,keyName)
);

insert into onetSequence values(1,2);
insert into onetSequence values(4,2);
insert into onetUser values(1,'admin','7a57a5a743894a0e',' ',0,0,' ',' ',1119358440630,1119358440630);
insert into onetUserPerm values(1,-1,1,1,1);




