CREATE TABLE `Membership` (
  `ID` int(11) NOT NULL auto_increment,
  `OID` int(11) default NULL,
  `UID` varchar(255) default NULL,
  PRIMARY KEY  (`ID`),
  UNIQUE KEY `ID` (`ID`),
  UNIQUE KEY `ID_2` (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=utf8

CREATE TABLE `Organization` (
  `ID` int(11) NOT NULL auto_increment,
  `Title` varchar(255) default NULL,
  PRIMARY KEY  (`ID`),
  UNIQUE KEY `ID` (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=utf8

CREATE TABLE `answers` (
  `ID` int(11) NOT NULL auto_increment,
  `sessID` int(11) default NULL,
  `uname` char(255) default NULL,
  `testID` int(11) default NULL,
  `questionID` int(11) default NULL,
  `points` double(10,2) default NULL,
  `variables` char(255) default NULL,
  `time` timestamp NOT NULL default CURRENT_TIMESTAMP,
  `submitted` char(255) default NULL,
  `answerHead` mediumblob,
  `answerBody` mediumblob,
  PRIMARY KEY  (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=85 DEFAULT CHARSET=utf8

CREATE TABLE `grouptable` (
  `userid` char(10) default NULL,
  `groupid` char(20) default NULL,
  `id` int(11) NOT NULL auto_increment,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `id` (`id`),
  UNIQUE KEY `id_2` (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=19 DEFAULT CHARSET=utf8

CREATE TABLE `questions` (
  `ID` int(11) NOT NULL auto_increment,
  `owner` varchar(255) default NULL,
  `question` varchar(255) default NULL,
  `html` blob,
  `description` text,
  `xmlname` varchar(255) default NULL,
  `orgID` int(11) default NULL,
  `guid` varchar(255) default NULL,
  `status` int(2) default NULL,
  `head` mediumblob,
  `body` mediumblob,
  `pointvariables` char(255) default NULL,
  `othervariables` char(255) default NULL,
  `keywords` mediumtext character set utf8 collate utf8_unicode_ci,
  `title` varchar(1000) default NULL,
  `zipID` int(11) default NULL,
  `difficulty` varchar(1000) default NULL,
  `licence` varchar(1000) default NULL,
  `licencetype` char(255) default NULL,
  PRIMARY KEY  (`ID`),
  UNIQUE KEY `ID` (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8


CREATE TABLE `registrations` (
  `id` int(11) NOT NULL auto_increment,
  `email` varchar(255) default NULL,
  `password` varchar(255) default NULL,
  `userid` varchar(255) default NULL,
  `organization` int(11) default NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `ID` (`id`),
  UNIQUE KEY `id_2` (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=utf8

CREATE TABLE `subgroups` (
  `ID` int(11) NOT NULL auto_increment,
  `orgID` int(11) default NULL,
  `title` char(255) default NULL,
  `members` text,
  PRIMARY KEY  (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=utf8

CREATE TABLE `test_quiz` (
  `ID` int(11) NOT NULL auto_increment,
  `testID` int(11) default NULL,
  `questionID` int(11) default NULL,
  `pos` int(11) default NULL,
  PRIMARY KEY  (`ID`),
  UNIQUE KEY `ID` (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=38 DEFAULT CHARSET=utf8

CREATE TABLE `usertable` (
  `userid` varchar(10) NOT NULL,
  `password` varchar(32) NOT NULL,
  `email` varchar(255) default NULL,
  PRIMARY KEY  (`userid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8

CREATE TABLE profile (
    userid varchar(10) NOT NULL,
    email varchar(255) DEFAULT 'not used here',
    firstname varchar(255),
    lastname varchar(255),
    language varchar(3),
    image longblob,
    country varchar(5),
    mobile varchar(25),
    info mediumblob,
    contentType char(255) DEFAULT NULL,
    PRIMARY KEY (userid)
) engine=MyISAM DEFAULT CHARSET=utf8

CREATE TABLE `tests` (
  `ID` int(11) NOT NULL auto_increment,
  `owner` char(255) default NULL,
  `title` char(255) default NULL,
  `orgID` int(11) default NULL,
  `status` int(2) default NULL,

  timelimit_applied int(2) default 0,
  timelimit_start timestamp,
  timelimit_end timestamp,

  repeats int(5) default 1,

  PRIMARY KEY  (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=utf8 

CREATE TABLE `set_questions` (
  `ID` int(11) NOT NULL auto_increment,
  `setID` int(11) NOT NULL,
  `questionID` int(11) default NULL,
  `pos` int(11) default NULL,
  `preview` int(1) default NULL,
  PRIMARY KEY  (`ID`),
  UNIQUE KEY `ID` (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=10 DEFAULT CHARSET=utf8

CREATE TABLE `sets` (
  `ID` int(11) NOT NULL auto_increment,
  `orgID` int(11) default NULL,
  `title` char(255) default NULL,
  `creator` char(255) default NULL,
  `description` varchar(1000) default NULL,
  `pricing_model` int(3) default NULL,
  `view_price` double(10,2) default NULL,
  `one_month_price` double(10,2) default NULL,
  `three_month_price` double(10,2) default NULL,
  `six_month_price` double(10,2) default NULL,
  `isPublic` tinyint(1) default '0',
  PRIMARY KEY  (`ID`),
  UNIQUE KEY `ID` (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8

CREATE TABLE `subscriptions` (
  `ID` int(11) NOT NULL auto_increment,
  `setID` int(11) default NULL,
  `orgID` int(11) default NULL,
  `pricing_model` int(3) default NULL,
  `period_start` timestamp NOT NULL default CURRENT_TIMESTAMP,
  `period_end` timestamp NOT NULL default '0000-00-00 00:00:00',
  PRIMARY KEY  (`ID`),
  UNIQUE KEY `ID` (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8

CREATE TABLE `zipstore` (
  `id` int(11) NOT NULL auto_increment,
  `zip` longblob,
  `filename` char(255) collate utf8_bin default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=50 DEFAULT CHARSET=utf8 COLLATE=utf8_bin

CREATE TABLE `usages` (
  `ID` int(11) NOT NULL auto_increment,
  PRIMARY KEY  (`ID`),
  UNIQUE KEY `ID` (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8


/* Table for pay-per-view billing */
CREATE TABLE `billing` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `billtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `uname` varchar(10),
    `sessID` int(11) default NULL,
    `questionID` int(11),
    `setID` int(11),
    `orgID` int(11),
    PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_bin 
