SET FOREIGN_KEY_CHECKS = 0

drop table if exists `biodatabase`;

CREATE TABLE `biodatabase` (
  `biodatabase_id` int(10) unsigned NOT NULL auto_increment,
  `name` varchar(40) NOT NULL default '',
  `comments` mediumtext,
  PRIMARY KEY  (`biodatabase_id`),
  KEY `biodatabaseidx1` (`name`)
) TYPE=MyISAM;


drop table if exists `bioentry`;

CREATE TABLE `bioentry` (
  `bioentry_id` int(10) unsigned NOT NULL auto_increment,
  `biodatabase_id` int(10) NOT NULL default '0',
  `display_id` varchar(40) NOT NULL default '',
  `accession` varchar(40) NOT NULL default '',
  `primary_id` varchar(40) default NULL,
  `entry_version` int(10) default NULL,
  `division` varchar(5) NOT NULL default '',
  PRIMARY KEY  (`bioentry_id`),
  UNIQUE KEY `biodatabase_id` (`biodatabase_id`,`accession`,`entry_version`,`division`),
  KEY `bioentrydbid` (`biodatabase_id`),
  KEY `bioentrydid` (`display_id`),
  KEY `bioentryacc` (`accession`),
  KEY `bioentryprim` (`primary_id`)
) TYPE=MyISAM;


drop table if exists `bioentry_direct_links`;

CREATE TABLE `bioentry_direct_links` (
  `bio_dblink_id` int(10) unsigned NOT NULL auto_increment,
  `source_bioentry_id` int(10) NOT NULL default '0',
  `dbxref_id` int(10) NOT NULL default '0',
  PRIMARY KEY  (`bio_dblink_id`),
  KEY `bdl1` (`source_bioentry_id`),
  KEY `bdl2` (`dbxref_id`)
) TYPE=MyISAM;


drop table if exists `bioentry_qualifier_value`;

CREATE TABLE `bioentry_qualifier_value` (
  `bioentry_id` int(10) unsigned NOT NULL default '0',
  `ontology_term_id` int(10) unsigned NOT NULL default '0',
  `qualifier_value` mediumtext,
  KEY `bqv1` (`bioentry_id`),
  KEY `bqv2` (`ontology_term_id`),
  KEY `bqv3` (`bioentry_id`,`ontology_term_id`),
  FULLTEXT KEY `text` (`qualifier_value`)
) TYPE=MyISAM;


drop table if exists `bioentry_reference`;

CREATE TABLE `bioentry_reference` (
  `bioentry_id` int(10) unsigned NOT NULL default '0',
  `reference_id` int(10) unsigned NOT NULL default '0',
  `reference_start` int(10) default NULL,
  `reference_end` int(10) default NULL,
  `reference_rank` int(5) unsigned NOT NULL default '0',
  PRIMARY KEY  (`bioentry_id`,`reference_id`,`reference_rank`),
  KEY `reference_rank_idx` (`reference_rank`),
  KEY `reference_rank_idx2` (`bioentry_id`),
  KEY `reference_rank_idx3` (`reference_id`),
  KEY `reference_rank_idx4` (`reference_rank`),
  KEY `reference_rank_idx5` (`bioentry_id`,`reference_rank`)
) TYPE=MyISAM;


drop table if exists `bioentry_taxa`;

CREATE TABLE `bioentry_taxa` (
  `bioentry_id` int(10) NOT NULL default '0',
  `taxa_id` int(10) NOT NULL default '0',
  PRIMARY KEY  (`bioentry_id`),
  KEY `bioentrytax` (`taxa_id`)
) TYPE=MyISAM;


drop table if exists `biosequence`;

CREATE TABLE `biosequence` (
  `biosequence_id` int(10) unsigned NOT NULL auto_increment,
  `bioentry_id` int(10) NOT NULL default '0',
  `seq_version` int(6) default NULL,
  `seq_length` int(10) default NULL,
  `biosequence_str` mediumtext,
  `molecule` varchar(10) default NULL,
  PRIMARY KEY  (`biosequence_id`),
  UNIQUE KEY `bioentry_id` (`bioentry_id`),
  KEY `biosequenceeid` (`bioentry_id`)
) TYPE=MyISAM;


drop table if exists `cache_corba_support`;

CREATE TABLE `cache_corba_support` (
  `biodatabase_id` int(10) unsigned NOT NULL default '0',
  `http_ior_string` varchar(255) default NULL,
  `direct_ior_string` varchar(255) default NULL,
  PRIMARY KEY  (`biodatabase_id`)
) TYPE=MyISAM;


drop table if exists `comment`;

CREATE TABLE `comment` (
  `comment_id` int(10) unsigned NOT NULL auto_increment,
  `bioentry_id` int(10) NOT NULL default '0',
  `comment_text` mediumtext NOT NULL,
  `comment_rank` int(5) NOT NULL default '0',
  PRIMARY KEY  (`comment_id`),
  UNIQUE KEY `bioentry_id` (`bioentry_id`,`comment_rank`),
  KEY `cmtidx1` (`bioentry_id`)
) TYPE=MyISAM;


drop table if exists `dbxref`;

CREATE TABLE `dbxref` (
  `dbxref_id` int(10) unsigned NOT NULL auto_increment,
  `dbname` varchar(40) NOT NULL default '',
  `accession` varchar(40) NOT NULL default '',
  PRIMARY KEY  (`dbxref_id`),
  UNIQUE KEY `dbname` (`dbname`,`accession`),
  KEY `dbxrefdbn` (`dbname`),
  KEY `dbxrefacc` (`accession`)
) TYPE=MyISAM;


drop table if exists `dbxref_qualifier_value`;

CREATE TABLE `dbxref_qualifier_value` (
  `dbxref_qualifier_value_id` int(10) unsigned NOT NULL auto_increment,
  `dbxref_id` int(10) NOT NULL default '0',
  `ontology_term_id` int(10) unsigned NOT NULL default '0',
  `qualifier_value` mediumtext,
  PRIMARY KEY  (`dbxref_qualifier_value_id`),
  KEY `dqv1` (`dbxref_id`),
  KEY `dqv2` (`ontology_term_id`)
) TYPE=MyISAM;


drop table if exists `location_qualifier_value`;

CREATE TABLE `location_qualifier_value` (
  `seqfeature_location_id` int(10) unsigned NOT NULL default '0',
  `ontology_term_id` int(10) NOT NULL default '0',
  `qualifier_value` char(255) NOT NULL default '',
  `qualifier_int_value` int(10) default NULL,
  KEY `lqv1` (`seqfeature_location_id`),
  KEY `lqv2` (`ontology_term_id`)
) TYPE=MyISAM;


drop table if exists `ontology_term`;

CREATE TABLE `ontology_term` (
  `ontology_term_id` int(10) unsigned NOT NULL auto_increment,
  `term_name` varchar(255) default NULL,
  `term_definition` mediumtext,
  PRIMARY KEY  (`ontology_term_id`),
  KEY `otn` (`term_name`)
) TYPE=MyISAM;


drop table if exists `reference`;

CREATE TABLE `reference` (
  `reference_id` int(10) unsigned NOT NULL auto_increment,
  `reference_location` mediumtext NOT NULL,
  `reference_title` mediumtext,
  `reference_authors` mediumtext NOT NULL,
  `reference_medline` int(10) default NULL,
  PRIMARY KEY  (`reference_id`),
  KEY `medlineidx` (`reference_medline`)
) TYPE=MyISAM;


drop table if exists `remote_seqfeature_name`;

CREATE TABLE `remote_seqfeature_name` (
  `seqfeature_location_id` int(10) unsigned NOT NULL default '0',
  `accession` varchar(40) NOT NULL default '',
  `version` int(10) NOT NULL default '0',
  PRIMARY KEY  (`seqfeature_location_id`),
  KEY `rsfn1` (`seqfeature_location_id`)
) TYPE=MyISAM;


drop table if exists `seqfeature`;

CREATE TABLE `seqfeature` (
  `seqfeature_id` int(10) unsigned NOT NULL auto_increment,
  `bioentry_id` int(10) NOT NULL default '0',
  `seqfeature_key_id` int(10) default NULL,
  `seqfeature_source_id` int(10) default NULL,
  `seqfeature_rank` int(5) default NULL,
  PRIMARY KEY  (`seqfeature_id`),
  KEY `sf1` (`seqfeature_key_id`),
  KEY `sf2` (`seqfeature_source_id`),
  KEY `sf3` (`bioentry_id`)
) TYPE=MyISAM;


drop table if exists `seqfeature_location`;

CREATE TABLE `seqfeature_location` (
  `seqfeature_location_id` int(10) unsigned NOT NULL auto_increment,
  `seqfeature_id` int(10) NOT NULL default '0',
  `seq_start` int(10) default NULL,
  `seq_end` int(10) default NULL,
  `seq_strand` int(1) NOT NULL default '0',
  `location_rank` int(5) NOT NULL default '0',
  PRIMARY KEY  (`seqfeature_location_id`),
  UNIQUE KEY `seqfeature_id` (`seqfeature_id`,`location_rank`),
  KEY `sfl1` (`seqfeature_id`),
  KEY `sfl2` (`seq_start`),
  KEY `sfl3` (`seq_end`)
) TYPE=MyISAM;


drop table if exists `seqfeature_qualifier_value`;

CREATE TABLE `seqfeature_qualifier_value` (
  `seqfeature_id` int(10) NOT NULL default '0',
  `ontology_term_id` int(10) NOT NULL default '0',
  `qualifier_rank` int(5) NOT NULL default '0',
  `qualifier_value` mediumtext NOT NULL,
  PRIMARY KEY  (`seqfeature_id`,`ontology_term_id`,`qualifier_rank`),
  KEY `sqv1` (`ontology_term_id`),
  KEY `sqv3` (`seqfeature_id`)
) TYPE=MyISAM;


drop table if exists `seqfeature_relationship`;

CREATE TABLE `seqfeature_relationship` (
  `seqfeature_relationship_id` int(10) unsigned NOT NULL auto_increment,
  `parent_seqfeature_id` int(10) NOT NULL default '0',
  `child_seqfeature_id` int(10) NOT NULL default '0',
  `relationship_type_id` int(10) NOT NULL default '0',
  `relationship_rank` int(5) default NULL,
  PRIMARY KEY  (`seqfeature_relationship_id`),
  UNIQUE KEY `parent_seqfeature_id` (`parent_seqfeature_id`,`child_seqfeature_id`,`relationship_type_id`),
  KEY `sfr1` (`relationship_type_id`),
  KEY `sfr2` (`parent_seqfeature_id`),
  KEY `sfr3` (`child_seqfeature_id`)
) TYPE=MyISAM;


drop table if exists `seqfeature_source`;

CREATE TABLE `seqfeature_source` (
  `seqfeature_source_id` int(10) unsigned NOT NULL auto_increment,
  `source_name` varchar(255) NOT NULL default '',
  PRIMARY KEY  (`seqfeature_source_id`)
) TYPE=MyISAM;


drop table if exists `taxa`;

CREATE TABLE `taxa` (
  `taxa_id` int(10) unsigned NOT NULL auto_increment,
  `full_lineage` mediumtext NOT NULL,
  `common_name` varchar(255) NOT NULL default '',
  `ncbi_taxa_id` int(10) default NULL,
  PRIMARY KEY  (`taxa_id`),
  KEY `taxancbi` (`ncbi_taxa_id`),
  KEY `taxaname` (`common_name`)
) TYPE=MyISAM;


SET FOREIGN_KEY_CHECKS = 1