SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL'; DROP SCHEMA IF EXISTS `hobused` ; CREATE SCHEMA IF NOT EXISTS `hobused` DEFAULT CHARACTER SET utf8 COLLATE utf8_estonian_ci ; USE `hobused` ; -- ----------------------------------------------------- -- Table `hobused`.`t6ud` -- ----------------------------------------------------- DROP TABLE IF EXISTS `hobused`.`t6ud` ; CREATE TABLE IF NOT EXISTS `hobused`.`t6ud` ( `idt6ud` INT NOT NULL AUTO_INCREMENT , PRIMARY KEY (`idt6ud`) ) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `hobused`.`hobused` -- ----------------------------------------------------- DROP TABLE IF EXISTS `hobused`.`hobused` ; CREATE TABLE IF NOT EXISTS `hobused`.`hobused` ( `idhobused` INT NOT NULL AUTO_INCREMENT , `t6ud_idt6ud` INT NOT NULL , `nimi` VARCHAR(30) NULL , `synniaeg` DATE NULL , PRIMARY KEY (`idhobused`) , INDEX `fk_hobused_t6ud` (`t6ud_idt6ud` ASC) , CONSTRAINT `fk_hobused_t6ud` FOREIGN KEY (`t6ud_idt6ud` ) REFERENCES `hobused`.`t6ud` (`idt6ud` ) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `hobused`.`ravimid` -- ----------------------------------------------------- DROP TABLE IF EXISTS `hobused`.`ravimid` ; CREATE TABLE IF NOT EXISTS `hobused`.`ravimid` ( `idravimid` INT NOT NULL AUTO_INCREMENT , PRIMARY KEY (`idravimid`) ) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `hobused`.`protseduurid` -- ----------------------------------------------------- DROP TABLE IF EXISTS `hobused`.`protseduurid` ; CREATE TABLE IF NOT EXISTS `hobused`.`protseduurid` ( `idprotseduurid` INT NOT NULL AUTO_INCREMENT , `ravimid_idravimid` INT NOT NULL , PRIMARY KEY (`idprotseduurid`) , INDEX `fk_protseduurid_ravimid1` (`ravimid_idravimid` ASC) , CONSTRAINT `fk_protseduurid_ravimid1` FOREIGN KEY (`ravimid_idravimid` ) REFERENCES `hobused`.`ravimid` (`idravimid` ) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `hobused`.`peremehed` -- ----------------------------------------------------- DROP TABLE IF EXISTS `hobused`.`peremehed` ; CREATE TABLE IF NOT EXISTS `hobused`.`peremehed` ( `idperemehed` INT NOT NULL AUTO_INCREMENT , PRIMARY KEY (`idperemehed`) ) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `hobused`.`arstid` -- ----------------------------------------------------- DROP TABLE IF EXISTS `hobused`.`arstid` ; CREATE TABLE IF NOT EXISTS `hobused`.`arstid` ( `idarstid` INT NOT NULL AUTO_INCREMENT , PRIMARY KEY (`idarstid`) ) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `hobused`.`kylastused` -- ----------------------------------------------------- DROP TABLE IF EXISTS `hobused`.`kylastused` ; CREATE TABLE IF NOT EXISTS `hobused`.`kylastused` ( `idkylastused` INT NOT NULL AUTO_INCREMENT , `arstid_idarstid` INT NOT NULL , `hobused_idhobused` INT NOT NULL , `protseduurid_idprotseduurid` INT NOT NULL , PRIMARY KEY (`idkylastused`) , INDEX `fk_kylastused_arstid1` (`arstid_idarstid` ASC) , INDEX `fk_kylastused_hobused1` (`hobused_idhobused` ASC) , INDEX `fk_kylastused_protseduurid1` (`protseduurid_idprotseduurid` ASC) , CONSTRAINT `fk_kylastused_arstid1` FOREIGN KEY (`arstid_idarstid` ) REFERENCES `hobused`.`arstid` (`idarstid` ) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_kylastused_hobused1` FOREIGN KEY (`hobused_idhobused` ) REFERENCES `hobused`.`hobused` (`idhobused` ) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_kylastused_protseduurid1` FOREIGN KEY (`protseduurid_idprotseduurid` ) REFERENCES `hobused`.`protseduurid` (`idprotseduurid` ) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `hobused`.`ravi` -- ----------------------------------------------------- DROP TABLE IF EXISTS `hobused`.`ravi` ; CREATE TABLE IF NOT EXISTS `hobused`.`ravi` ( `idravi` INT NOT NULL AUTO_INCREMENT , `aeg` DATETIME NOT NULL DEFAULT now() , `arstid_idarstid` INT NOT NULL , `hobused_idhobused` INT NOT NULL , `protseduurid_idprotseduurid` INT NOT NULL , PRIMARY KEY (`idravi`) , INDEX `fk_ravi_arstid1` (`arstid_idarstid` ASC) , INDEX `fk_ravi_hobused1` (`hobused_idhobused` ASC) , INDEX `fk_ravi_protseduurid1` (`protseduurid_idprotseduurid` ASC) , CONSTRAINT `fk_ravi_arstid1` FOREIGN KEY (`arstid_idarstid` ) REFERENCES `hobused`.`arstid` (`idarstid` ) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_ravi_hobused1` FOREIGN KEY (`hobused_idhobused` ) REFERENCES `hobused`.`hobused` (`idhobused` ) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_ravi_protseduurid1` FOREIGN KEY (`protseduurid_idprotseduurid` ) REFERENCES `hobused`.`protseduurid` (`idprotseduurid` ) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `hobused`.`arved` -- ----------------------------------------------------- DROP TABLE IF EXISTS `hobused`.`arved` ; CREATE TABLE IF NOT EXISTS `hobused`.`arved` ( `idarved` INT NOT NULL AUTO_INCREMENT , PRIMARY KEY (`idarved`) ) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `hobused`.`omandus` -- ----------------------------------------------------- DROP TABLE IF EXISTS `hobused`.`omandus` ; CREATE TABLE IF NOT EXISTS `hobused`.`omandus` ( `idomandus` INT NOT NULL AUTO_INCREMENT , `peremehed_idperemehed` INT NOT NULL , `hobused_idhobused` INT NOT NULL , PRIMARY KEY (`idomandus`) , INDEX `fk_omandus_peremehed1` (`peremehed_idperemehed` ASC) , INDEX `fk_omandus_hobused1` (`hobused_idhobused` ASC) , CONSTRAINT `fk_omandus_peremehed1` FOREIGN KEY (`peremehed_idperemehed` ) REFERENCES `hobused`.`peremehed` (`idperemehed` ) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_omandus_hobused1` FOREIGN KEY (`hobused_idhobused` ) REFERENCES `hobused`.`hobused` (`idhobused` ) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `hobused`.`arverida` -- ----------------------------------------------------- DROP TABLE IF EXISTS `hobused`.`arverida` ; CREATE TABLE IF NOT EXISTS `hobused`.`arverida` ( `idarverida` INT NOT NULL AUTO_INCREMENT , `arved_idarved` INT NOT NULL , `ravimid_idravimid` INT NOT NULL , `kylastused_idkylastused` INT NOT NULL , PRIMARY KEY (`idarverida`) , INDEX `fk_arverida_arved1` (`arved_idarved` ASC) , INDEX `fk_arverida_ravimid1` (`ravimid_idravimid` ASC) , INDEX `fk_arverida_kylastused1` (`kylastused_idkylastused` ASC) , CONSTRAINT `fk_arverida_arved1` FOREIGN KEY (`arved_idarved` ) REFERENCES `hobused`.`arved` (`idarved` ) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_arverida_ravimid1` FOREIGN KEY (`ravimid_idravimid` ) REFERENCES `hobused`.`ravimid` (`idravimid` ) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_arverida_kylastused1` FOREIGN KEY (`kylastused_idkylastused` ) REFERENCES `hobused`.`kylastused` (`idkylastused` ) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; SET SQL_MODE=@OLD_SQL_MODE; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;