-- phpMyAdmin SQL Dump
-- version 3.4.11.1deb1
-- http://www.phpmyadmin.net
--
-- Počítač: localhost
-- Vygenerováno: Úte 13. lis 2012, 21:55
-- Verze MySQL: 5.5.28
-- Verze PHP: 5.4.6-1ubuntu1

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";

--
-- Databáze: `dochazka`
--

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

--
-- Struktura tabulky `Attendance`
--

CREATE TABLE IF NOT EXISTS `Attendance` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `User` int(11) NOT NULL,
  `TimeFrom` time NOT NULL,
  `TimeTo` time NOT NULL,
  PRIMARY KEY (`Id`),
  KEY `User` (`User`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

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

--
-- Struktura tabulky `Holiday`
--

CREATE TABLE IF NOT EXISTS `Holiday` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Date` date NOT NULL,
  `Name` varchar(255) CHARACTER SET utf8 COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

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

--
-- Struktura tabulky `Log`
--

CREATE TABLE IF NOT EXISTS `Log` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Time` datetime NOT NULL,
  `User` int(11) NOT NULL,
  `Text` varchar(255) CHARACTER SET utf8 COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`Id`),
  KEY `User` (`User`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

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

--
-- Struktura tabulky `Operation`
--

CREATE TABLE IF NOT EXISTS `Operation` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) CHARACTER SET utf8 COLLATE utf8_czech_ci NOT NULL,
  `KeyId` int(11) NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

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

--
-- Struktura tabulky `Passage`
--

CREATE TABLE IF NOT EXISTS `Passage` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Time` datetime NOT NULL,
  `User` int(11) NOT NULL,
  `Operation` int(11) NOT NULL,
  `Terminal` int(11) NOT NULL,
  PRIMARY KEY (`Id`),
  KEY `Terminal` (`Terminal`),
  KEY `Operation` (`Operation`),
  KEY `User` (`User`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

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

--
-- Struktura tabulky `Terminal`
--

CREATE TABLE IF NOT EXISTS `Terminal` (
  `Id` int(11) NOT NULL,
  `Name` varchar(255) CHARACTER SET utf8 COLLATE utf8_czech_ci NOT NULL,
  `Enabled` tinyint(1) NOT NULL,
  `Addreess` varchar(255) CHARACTER SET utf8 COLLATE utf8_czech_ci NOT NULL,
  `Port` int(11) NOT NULL,
  `Type` int(11) NOT NULL,
  `Note` text CHARACTER SET utf8 COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

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

--
-- Struktura tabulky `User`
--

CREATE TABLE IF NOT EXISTS `User` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Login` varchar(255) CHARACTER SET utf8 COLLATE utf8_czech_ci NOT NULL,
  `Password` varchar(255) CHARACTER SET utf8 COLLATE utf8_czech_ci NOT NULL,
  `FirstName` varchar(255) CHARACTER SET utf8 COLLATE utf8_czech_ci NOT NULL,
  `SecondName` varchar(255) CHARACTER SET utf8 COLLATE utf8_czech_ci NOT NULL,
  `Enabled` tinyint(1) NOT NULL,
  `CardCode` varchar(255) CHARACTER SET utf8 COLLATE utf8_czech_ci NOT NULL,
  `Fingerprint` varchar(255) CHARACTER SET utf8 COLLATE utf8_czech_ci NOT NULL,
  `Note` int(11) NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

--
-- Omezení pro exportované tabulky
--

--
-- Omezení pro tabulku `Attendance`
--
ALTER TABLE `Attendance`
  ADD CONSTRAINT `Attendance_ibfk_1` FOREIGN KEY (`User`) REFERENCES `User` (`Id`);

--
-- Omezení pro tabulku `Log`
--
ALTER TABLE `Log`
  ADD CONSTRAINT `Log_ibfk_1` FOREIGN KEY (`User`) REFERENCES `User` (`Id`);

--
-- Omezení pro tabulku `Passage`
--
ALTER TABLE `Passage`
  ADD CONSTRAINT `Passage_ibfk_3` FOREIGN KEY (`Terminal`) REFERENCES `Terminal` (`Id`),
  ADD CONSTRAINT `Passage_ibfk_1` FOREIGN KEY (`User`) REFERENCES `User` (`Id`),
  ADD CONSTRAINT `Passage_ibfk_2` FOREIGN KEY (`Operation`) REFERENCES `Operation` (`Id`);
