 SET foreign_key_checks = 0;
 SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
 
-DROP DATABASE `tarallo`;
+DROP DATABASE IF EXISTS `tarallo`;
 CREATE DATABASE `tarallo` DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci /*!40100 DEFAULT CHARACTER SET utf8mb4 */;
 USE `tarallo`;
 

  PRIMARY KEY (`ModificationID`,`ParentFrom`,`ParentTo`),
  KEY `ParentFrom` (`ParentFrom`),
  KEY `ParentTo` (`ParentTo`),
  CONSTRAINT `ItemLocationModification_ibfk_2` FOREIGN KEY (`ModificationID`) REFERENCES `Modification` (`ModificationID`) ON DELETE NO ACTION ON UPDATE CASCADE,
  CONSTRAINT `ItemLocationModification_ibfk_3` FOREIGN KEY (`ParentFrom`) REFERENCES `Item` (`ItemID`) ON DELETE NO ACTION ON UPDATE CASCADE,
  CONSTRAINT `ItemLocationModification_ibfk_4` FOREIGN KEY (`ParentTo`) REFERENCES `Item` (`ItemID`) ON DELETE NO ACTION ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;



	`ValueText` text DEFAULT NULL,
  PRIMARY KEY (`FeatureID`,`ItemID`),
  KEY `ItemID` (`ItemID`),
  KEY `Value` (`Value`),
  CONSTRAINT `ItemFeature_ibfk_1` FOREIGN KEY (`ItemID`) REFERENCES `Item` (`ItemID`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `ItemFeature_ibfk_2` FOREIGN KEY (`FeatureID`) REFERENCES `Feature` (`FeatureID`) ON DELETE NO ACTION ON UPDATE CASCADE,
	CHECK((`Value` IS NOT NULL AND `ValueText` IS NULL)
  OR (`Value` IS NULL AND `ValueText` IS NOT NULL))

