-- Neural Mesh Install SQL Dump
-- v1.6.7




--
-- Database: `nmesh`
--

-- --------------------------------------------------------

--
-- Table structure for table `cache`
--

CREATE TABLE IF NOT EXISTS `nn_cache` (
  `cacheID` varchar(32) NOT NULL,
  `networkID` int(5) unsigned NOT NULL,
  `cacheContent` longtext NOT NULL,
  `cacheDate` datetime NOT NULL,
  PRIMARY KEY (`cacheID`),
  KEY `networkID` (`networkID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `epochs`
--

CREATE TABLE IF NOT EXISTS `nn_epochs` (
  `epochID` int(6) unsigned NOT NULL AUTO_INCREMENT,
  `networkID` int(5) unsigned NOT NULL,
  `iterations` int(6) unsigned NOT NULL,
  `startMSE` decimal(10,9) unsigned NOT NULL,
  `endMSE` decimal(10,9) unsigned NOT NULL,
  `epochDate` datetime NOT NULL,
  `execTime` decimal(15,8) unsigned NOT NULL DEFAULT '0.00000000',
  `trainsetID` int(5) DEFAULT NULL,
  PRIMARY KEY (`epochID`),
  KEY `networkID` (`networkID`),
  KEY `trainsetID` (`trainsetID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `patterns`
--

CREATE TABLE IF NOT EXISTS `nn_patterns` (
  `patternID` int(5) unsigned NOT NULL AUTO_INCREMENT,
  `trainsetID` int(5) unsigned NOT NULL,
  `pattern` varchar(255) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL,
  `output` varchar(255) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL,
  PRIMARY KEY (`patternID`),
  KEY `train` (`trainsetID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `trainsets`
--

CREATE TABLE IF NOT EXISTS `nn_trainsets` (
  `trainsetID` int(5) unsigned NOT NULL AUTO_INCREMENT,
  `networkID` int(5) unsigned NOT NULL,
  `label` varchar(20) NOT NULL,
  PRIMARY KEY (`trainsetID`),
  KEY `network` (`networkID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `usernetwork`
--

CREATE TABLE IF NOT EXISTS `nn_usernetwork` (
  `userID` int(5) NOT NULL,
  `networkID` int(5) unsigned NOT NULL,
  PRIMARY KEY (`userID`,`networkID`),
  KEY `networkID` (`networkID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `cache`
--
ALTER TABLE `nn_cache`
  ADD CONSTRAINT `networkID_fk` FOREIGN KEY (`networkID`) REFERENCES `networks` (`networkID`) ON DELETE CASCADE;

--
-- Constraints for table `epochs`
--
ALTER TABLE `nn_epochs`
  ADD CONSTRAINT `epochs_ibfk_1` FOREIGN KEY (`networkID`) REFERENCES `networks` (`networkID`) ON DELETE CASCADE;

--
-- Constraints for table `patterns`
--
ALTER TABLE `nn_patterns`
  ADD CONSTRAINT `patterns_ibfk_1` FOREIGN KEY (`trainsetID`) REFERENCES `trainsets` (`trainsetID`) ON DELETE CASCADE;

--
-- Constraints for table `trainsets`
--
ALTER TABLE `nn_trainsets`
  ADD CONSTRAINT `trainsets_ibfk_1` FOREIGN KEY (`networkID`) REFERENCES `networks` (`networkID`) ON DELETE CASCADE;

--
-- Constraints for table `usernetwork`
--
ALTER TABLE `nn_usernetwork`
  ADD CONSTRAINT `usernetwork_ibfk_1` FOREIGN KEY (`userID`) REFERENCES `users` (`userID`) ON DELETE CASCADE,
  ADD CONSTRAINT `usernetwork_ibfk_2` FOREIGN KEY (`networkID`) REFERENCES `networks` (`networkID`) ON DELETE CASCADE;
