 -- -----------------------------------------------------
 DROP TABLE IF EXISTS `crawl`.`word_pages` ;
 
-CREATE TABLE IF NOT EXISTS `crawl`.`word_pages` (
-  `id` INT(11) NOT NULL AUTO_INCREMENT,
-  `word` INT(11) NULL DEFAULT NULL,
-  `page` INT(11) NULL DEFAULT NULL,
-  PRIMARY KEY (`id`),
-  INDEX `fk_word_pages_words_idx` (`word` ASC),
-  INDEX `fk_word_pages_pages_idx` (`page` ASC),
+CREATE  TABLE IF NOT EXISTS `crawl`.`word_pages` (
+  `id` INT(11) NOT NULL AUTO_INCREMENT ,
+  `word` INT(11) NULL DEFAULT NULL ,
+  `page` INT(11) NULL DEFAULT NULL ,
+  PRIMARY KEY (`id`) ,
+  INDEX `fk_word_pages_words_idx` (`word` ASC) ,
+  INDEX `fk_word_pages_pages_idx` (`page` ASC) ,
   CONSTRAINT `fk_word_pages_words`
-    FOREIGN KEY (`word`)
-    REFERENCES `crawl`.`words` (`id`)
+    FOREIGN KEY (`word` )
+    REFERENCES `crawl`.`words` (`id` )
     ON DELETE NO ACTION
     ON UPDATE NO ACTION,
   CONSTRAINT `fk_word_pages_pages`
-    FOREIGN KEY (`page`)
-    REFERENCES `crawl`.`pages` (`id`)
+    FOREIGN KEY (`page` )
+    REFERENCES `crawl`.`pages` (`id` )
     ON DELETE NO ACTION
     ON UPDATE NO ACTION)
 ENGINE = InnoDB
 DEFAULT CHARACTER SET = latin1;
 
 
+
 SET SQL_MODE=@OLD_SQL_MODE;
 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;

-- -----------------------------------------------------
DROP TABLE IF EXISTS `crawl`.`links` ;

CREATE TABLE IF NOT EXISTS `crawl`.`links` (
  `id` INT(11) NOT NULL AUTO_INCREMENT,
  `page_from` INT(11) NOT NULL,
  `page_to` INT(11) NOT NULL,
  `text` VARCHAR(2048) NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  INDEX `fk_page_from_idx` (`page_from` ASC),
  INDEX `fk_page_to_idx` (`page_to` ASC),
  INDEX `text_idx` (`text`(767) ASC),
  CONSTRAINT `fk_page_from`
    FOREIGN KEY (`page_from`)
    REFERENCES `crawl`.`pages` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_page_to`
    FOREIGN KEY (`page_to`)
    REFERENCES `crawl`.`pages` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
AUTO_INCREMENT = 86160
DEFAULT CHARACTER SET = latin1;



-- -----------------------------------------------------
DROP TABLE IF EXISTS `crawl`.`pages` ;

CREATE  TABLE IF NOT EXISTS `crawl`.`pages` (
  `id` INT(11) NOT NULL AUTO_INCREMENT ,
  `runid` INT(11) NOT NULL ,
  `url` VARCHAR(2048) NOT NULL ,
  `status` INT(11) NULL DEFAULT NULL ,
  `title` VARCHAR(2048) NULL DEFAULT NULL ,
  `text` MEDIUMTEXT NULL DEFAULT NULL ,
  PRIMARY KEY (`id`, `runid`) ,
  INDEX `fk_pages_runs_idx` (`runid` ASC) ,
  INDEX `idx_pages_url` (`url`(255) ASC) ,
  INDEX `idx_pages_status` (`status` ASC) ,
  CONSTRAINT `fk_pages_runs`
    FOREIGN KEY (`runid` )
    REFERENCES `crawl`.`runs` (`id` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
AUTO_INCREMENT = 91023
DEFAULT CHARACTER SET = utf8;


