-- http://www.phpmyadmin.net
--
-- Počítač: localhost
-- Vygenerováno: Pon 07. led 2013, 23:00
-- Verze MySQL: 5.1.60
-- Verze PHP: 5.3.8


--
-- Databáze: `is`
--

DELIMITER $$
--
-- Funkce
--
CREATE DEFINER=`centrala`@`localhost` FUNCTION `CompareNetworkPrefix`(Address1 INT(11) UNSIGNED, Address2 INT(11) UNSIGNED, Size INT(11)) RETURNS tinyint(1)
RETURN Address1 & (-1 << (32 - Size)) = Address2 & (-1 << (32 - Size))$$

DELIMITER ;

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

--
-- Struktura tabulky `ChatHistory`
--

CREATE TABLE IF NOT EXISTS `ChatHistory` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Nick` varchar(64) COLLATE utf8_czech_ci NOT NULL,
  `Text` text COLLATE utf8_czech_ci NOT NULL,
  `Time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `Color` int(11) NOT NULL DEFAULT '0',
  `RoomName` varchar(32) COLLATE utf8_czech_ci NOT NULL,
  `RoomType` int(11) NOT NULL DEFAULT '0',
  `Host` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=528576 ;

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

--
-- Struktura tabulky `Country`
--

CREATE TABLE IF NOT EXISTS `Country` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=4 ;

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

--
-- Struktura tabulky `DocumentLine`
--

CREATE TABLE IF NOT EXISTS `DocumentLine` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Shortcut` varchar(16) COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Shortcut` (`Shortcut`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=9 ;

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

--
-- Struktura tabulky `DocumentLineSequence`
--

CREATE TABLE IF NOT EXISTS `DocumentLineSequence` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `DocumentLine` int(11) NOT NULL,
  `FinanceYear` int(11) NOT NULL,
  `NextNumber` int(11) NOT NULL,
  `YearPrefix` int(11) NOT NULL,
  PRIMARY KEY (`Id`),
  KEY `DocumentLine` (`DocumentLine`),
  KEY `FinanceYear` (`FinanceYear`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=35 ;

--
-- RELACE PRO TABULKU `DocumentLineSequence`:
--   `DocumentLine`
--       `DocumentLine` -> `Id`
--   `FinanceYear`
--       `FinanceYear` -> `Id`
--

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

--
-- Struktura tabulky `EmailQueue`
--

CREATE TABLE IF NOT EXISTS `EmailQueue` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Time` datetime NOT NULL,
  `To` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Subject` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Content` text COLLATE utf8_czech_ci NOT NULL,
  `Headers` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Archive` int(11) NOT NULL DEFAULT '0',
  `From` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `AttachmentFile` int(11) DEFAULT NULL,
  PRIMARY KEY (`Id`),
  KEY `Archive` (`Archive`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=3052 ;

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

--
-- Struktura tabulky `File`
--

CREATE TABLE IF NOT EXISTS `File` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(256) COLLATE utf8_czech_ci NOT NULL,
  `Size` int(11) NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1 ;

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

--
-- Struktura tabulky `FinanceAssetsHistory`
--

CREATE TABLE IF NOT EXISTS `FinanceAssetsHistory` (
  `AssetsId` int(11) NOT NULL DEFAULT '0',
  `Time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `Text` varchar(255) COLLATE utf8_czech_ci NOT NULL DEFAULT '',
  `User` int(11) NOT NULL DEFAULT '0',
  KEY `AssetsId` (`AssetsId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;

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

--
-- Struktura tabulky `FinanceBankAccount`
--

CREATE TABLE IF NOT EXISTS `FinanceBankAccount` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `TimeCreate` date NOT NULL,
  `Number` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Comment` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=4 ;

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

--
-- Struktura tabulky `FinanceBillingPeriod`
--

CREATE TABLE IF NOT EXISTS `FinanceBillingPeriod` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `MonthCount` int(11) NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=6 ;

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

--
-- Struktura tabulky `FinanceBills`
--

CREATE TABLE IF NOT EXISTS `FinanceBills` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `TimeFrom` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `Subject` int(11) NOT NULL DEFAULT '0',
  `TimeTo` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `TimeCreate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `TimeDue` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `BillCode` varchar(32) COLLATE utf8_czech_ci NOT NULL,
  `Type` enum('invoice','income') COLLATE utf8_czech_ci NOT NULL,
  `Cash` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`Id`),
  KEY `Subject` (`Subject`),
  KEY `Subject_2` (`Subject`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=6204 ;

--
-- RELACE PRO TABULKU `FinanceBills`:
--   `Subject`
--       `Subject` -> `Id`
--

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

--
-- Struktura tabulky `FinanceBillsItems`
--

CREATE TABLE IF NOT EXISTS `FinanceBillsItems` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Bill` int(11) NOT NULL DEFAULT '0',
  `Description` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Price` float NOT NULL DEFAULT '0',
  `Quantity` float NOT NULL DEFAULT '1',
  PRIMARY KEY (`Id`),
  KEY `Bill` (`Bill`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=17745 ;

--
-- RELACE PRO TABULKU `FinanceBillsItems`:
--   `Bill`
--       `FinanceBills` -> `Id`
--

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

--
-- Struktura tabulky `FinanceCharge`
--

CREATE TABLE IF NOT EXISTS `FinanceCharge` (
  `Period` int(11) NOT NULL DEFAULT '0',
  `Internet` int(11) NOT NULL DEFAULT '0',
  `InternetSpeed` int(11) NOT NULL DEFAULT '0',
  `InternetSpeedReserve` int(11) NOT NULL DEFAULT '0',
  `AdministrationPerUser` int(20) NOT NULL DEFAULT '0',
  `kWh` int(11) NOT NULL DEFAULT '0',
  `BaseSpeedElement` int(11) NOT NULL DEFAULT '0',
  `BaseTariffPrice` int(11) NOT NULL DEFAULT '0',
  `TopTariffPrice` int(11) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;

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

--
-- Struktura tabulky `FinanceClaimsLiabilities`
--

CREATE TABLE IF NOT EXISTS `FinanceClaimsLiabilities` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `BillCode` varchar(16) COLLATE utf8_czech_ci NOT NULL,
  `Subject` int(11) NOT NULL DEFAULT '0',
  `TimeCreation` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `TimeDue` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `TimePayment` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `Value` float NOT NULL DEFAULT '0',
  `Bill` int(11) DEFAULT '0',
  `Text` varchar(255) COLLATE utf8_czech_ci NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`),
  KEY `Subject` (`Subject`),
  KEY `Bill` (`Bill`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=8670 ;

--
-- RELACE PRO TABULKU `FinanceClaimsLiabilities`:
--   `Subject`
--       `Subject` -> `Id`
--

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

--
-- Struktura tabulky `FinanceGroup`
--

CREATE TABLE IF NOT EXISTS `FinanceGroup` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Description` varchar(128) COLLATE utf8_czech_ci NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=4 ;

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

--
-- Struktura tabulky `FinanceLog`
--

CREATE TABLE IF NOT EXISTS `FinanceLog` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `Text` varchar(255) COLLATE utf8_czech_ci NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1 ;

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

--
-- Struktura tabulky `FinanceMonthlyOverall`
--

CREATE TABLE IF NOT EXISTS `FinanceMonthlyOverall` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Money` int(11) NOT NULL DEFAULT '0',
  `Date` date NOT NULL DEFAULT '0000-00-00',
  `Administration` int(11) NOT NULL DEFAULT '0',
  `kWh` int(11) NOT NULL DEFAULT '0',
  `AdministrationTotal` int(11) NOT NULL DEFAULT '0',
  `ConsumptionTotal` int(11) NOT NULL DEFAULT '0',
  `TotalPaid` int(11) NOT NULL DEFAULT '0',
  `BaseTariffPrice` int(11) NOT NULL DEFAULT '0',
  `TopTariffPrice` int(11) NOT NULL DEFAULT '0',
  `MemberCount` int(11) NOT NULL DEFAULT '0',
  `Investment` int(11) NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=121 ;

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

--
-- Struktura tabulky `FinanceOperation`
--

CREATE TABLE IF NOT EXISTS `FinanceOperation` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Time` datetime NOT NULL,
  `Subject` int(11) NOT NULL DEFAULT '0',
  `Cash` int(11) NOT NULL DEFAULT '0',
  `Value` float NOT NULL,
  `BillCode` varchar(32) COLLATE utf8_czech_ci DEFAULT NULL,
  `Taxable` tinyint(1) NOT NULL DEFAULT '1',
  `Bill` int(11) DEFAULT NULL,
  `Text` varchar(255) COLLATE utf8_czech_ci NOT NULL DEFAULT 'Vklad',
  `Network` int(11) NOT NULL DEFAULT '1',
  `BankAccount` int(11) DEFAULT NULL COMMENT 'FinanceBankAccount',
  `Treasury` int(11) DEFAULT NULL COMMENT 'FinanceTreasury',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `BillCode` (`BillCode`),
  UNIQUE KEY `BillCode_2` (`BillCode`),
  KEY `Subject` (`Subject`),
  KEY `Bill` (`Bill`),
  KEY `BankAccount` (`BankAccount`),
  KEY `Treasury` (`Treasury`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=6487 ;

--
-- RELACE PRO TABULKU `FinanceOperation`:
--   `Subject`
--       `Subject` -> `Id`
--   `Bill`
--       `FinanceBills` -> `Id`
--   `BankAccount`
--       `FinanceBankAccount` -> `Id`
--   `Treasury`
--       `FinanceTreasury` -> `Id`
--

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

--
-- Struktura tabulky `FinanceSmallAssets`
--

CREATE TABLE IF NOT EXISTS `FinanceSmallAssets` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Text` varchar(255) COLLATE utf8_czech_ci NOT NULL DEFAULT '',
  `PricePurchase` float NOT NULL DEFAULT '0',
  `TimeEnlistment` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `TimeElimination` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `SupplySubject` int(11) NOT NULL DEFAULT '0',
  `DeviceId` varchar(128) COLLATE utf8_czech_ci NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1 ;

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

--
-- Struktura tabulky `FinanceTariff`
--

CREATE TABLE IF NOT EXISTS `FinanceTariff` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(32) COLLATE utf8_czech_ci NOT NULL,
  `Group` int(11) NOT NULL DEFAULT '0',
  `SpeedMin` int(11) NOT NULL DEFAULT '0',
  `SpeedMax` int(11) NOT NULL DEFAULT '0',
  `UploadAsymmetry` int(11) NOT NULL DEFAULT '1',
  `Price` int(11) NOT NULL DEFAULT '0',
  `MemberCount` int(11) NOT NULL DEFAULT '0',
  `ReplaceId` int(11) DEFAULT NULL,
  `Public` int(11) NOT NULL DEFAULT '1',
  PRIMARY KEY (`Id`),
  KEY `ReplaceId` (`ReplaceId`),
  KEY `Public` (`Public`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=16 ;

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

--
-- Struktura tabulky `FinanceTreasury`
--

CREATE TABLE IF NOT EXISTS `FinanceTreasury` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `TimeCreate` date NOT NULL,
  `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=2 ;

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

--
-- Struktura tabulky `FinanceYear`
--

CREATE TABLE IF NOT EXISTS `FinanceYear` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Year` int(11) NOT NULL,
  `DateStart` date NOT NULL,
  `DateEnd` date NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=9 ;

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

--
-- Struktura tabulky `HostedProject`
--

CREATE TABLE IF NOT EXISTS `HostedProject` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Homepage` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `User` int(255) NOT NULL COMMENT 'User.Id',
  `TimeCreate` datetime NOT NULL,
  `Server` int(11) DEFAULT NULL COMMENT 'NetworkDevice.Id',
  `Active` int(11) NOT NULL DEFAULT '1',
  `WebHosting` int(11) NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=16 ;

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

--
-- Struktura tabulky `Hyperlink`
--

CREATE TABLE IF NOT EXISTS `Hyperlink` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `URL` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Group` int(11) NOT NULL,
  `IconFile` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `PermissionModule` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `PermissionOperation` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Enable` int(11) NOT NULL DEFAULT '1',
  PRIMARY KEY (`Id`),
  KEY `Group` (`Group`),
  KEY `Enable` (`Enable`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=68 ;

--
-- RELACE PRO TABULKU `Hyperlink`:
--   `Group`
--       `HyperlinkGroup` -> `Id`
--

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

--
-- Struktura tabulky `HyperlinkGroup`
--

CREATE TABLE IF NOT EXISTS `HyperlinkGroup` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=10 ;

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

--
-- Struktura tabulky `ISMenuItem`
--

CREATE TABLE IF NOT EXISTS `ISMenuItem` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Parent` int(11) DEFAULT NULL,
  `Table` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `IconName` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`Id`),
  KEY `Parent` (`Parent`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=38 ;

--
-- RELACE PRO TABULKU `ISMenuItem`:
--   `Parent`
--       `ISMenuItem` -> `Id`
--

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

--
-- Struktura tabulky `Language`
--

CREATE TABLE IF NOT EXISTS `Language` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=7 ;

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

--
-- Struktura tabulky `Log`
--

CREATE TABLE IF NOT EXISTS `Log` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `User` int(11) NOT NULL DEFAULT '0',
  `Module` varchar(64) COLLATE utf8_czech_ci NOT NULL DEFAULT '',
  `Operation` varchar(255) COLLATE utf8_czech_ci NOT NULL DEFAULT '',
  `Value` text COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`Id`),
  KEY `Time` (`Time`),
  KEY `User` (`User`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=37799 ;

--
-- RELACE PRO TABULKU `Log`:
--   `User`
--       `User` -> `Id`
--

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

--
-- Struktura tabulky `Meals`
--

CREATE TABLE IF NOT EXISTS `Meals` (
  `Date` date NOT NULL DEFAULT '0000-00-00',
  `Soup` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Meal` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Status` int(11) NOT NULL DEFAULT '0',
  UNIQUE KEY `date` (`Date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci ROW_FORMAT=DYNAMIC;

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

--
-- Struktura tabulky `MealsInfo`
--

CREATE TABLE IF NOT EXISTS `MealsInfo` (
  `Info` text COLLATE utf8_czech_ci NOT NULL,
  `Price` int(11) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci ROW_FORMAT=DYNAMIC;

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

--
-- Struktura tabulky `Member`
--

CREATE TABLE IF NOT EXISTS `Member` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Subject` int(11) NOT NULL,
  `ResponsibleUser` int(11) NOT NULL,
  `FamilyMemberCount` int(11) NOT NULL,
  `MembershipDate` date NOT NULL,
  `MemberState` int(11) NOT NULL,
  `InternetTariffCurrentMonth` int(11) NOT NULL,
  `InternetTariffNextMonth` int(11) NOT NULL,
  `GPS` int(11) NOT NULL,
  `BillingPeriod` int(11) NOT NULL DEFAULT '2',
  `NetworkSegment` int(11) DEFAULT NULL,
  `BillingPeriodNext` int(11) NOT NULL DEFAULT '2',
  `BillingPeriodLastDate` date NOT NULL,
  `Hire` float NOT NULL DEFAULT '0',
  `Blocked` int(11) NOT NULL DEFAULT '0',
  `PayDay` int(11) NOT NULL DEFAULT '1',
  PRIMARY KEY (`Id`),
  KEY `Subject` (`Subject`),
  KEY `ResponsibleUser` (`ResponsibleUser`),
  KEY `InternetTariffCurrentMonth` (`InternetTariffCurrentMonth`),
  KEY `InternetTariffNextMonth` (`InternetTariffNextMonth`),
  KEY `BillingPeriod` (`BillingPeriod`),
  KEY `BillingPeriodNext` (`BillingPeriodNext`),
  KEY `NetworkSegment` (`NetworkSegment`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=199 ;

--
-- RELACE PRO TABULKU `Member`:
--   `Subject`
--       `Subject` -> `Id`
--   `ResponsibleUser`
--       `User` -> `Id`
--   `InternetTariffCurrentMonth`
--       `FinanceTariff` -> `Id`
--   `InternetTariffNextMonth`
--       `FinanceTariff` -> `Id`
--   `BillingPeriod`
--       `FinanceBillingPeriod` -> `Id`
--   `BillingPeriodNext`
--       `FinanceBillingPeriod` -> `Id`
--

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

--
-- Struktura tabulky `MemberPayment`
--

CREATE TABLE IF NOT EXISTS `MemberPayment` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Member` int(11) NOT NULL,
  `MonthlyTotal` float NOT NULL,
  `MonthlyInternet` float NOT NULL,
  `MonthlyConsumption` float NOT NULL,
  `NetworkDevice` float NOT NULL,
  `MonthlyPlus` float NOT NULL,
  `Cash` float NOT NULL,
  PRIMARY KEY (`Id`),
  KEY `Member` (`Member`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=181 ;

--
-- RELACE PRO TABULKU `MemberPayment`:
--   `Member`
--       `Member` -> `Id`
--

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

--
-- Struktura tabulky `NetworkAP`
--

CREATE TABLE IF NOT EXISTS `NetworkAP` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `SSID` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Frequency` int(11) NOT NULL,
  `ChannelWidth` int(11) NOT NULL DEFAULT '20',
  `NetworkDevice` int(11) DEFAULT NULL,
  PRIMARY KEY (`Id`),
  KEY `NetworkDevice` (`NetworkDevice`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=45 ;

--
-- RELACE PRO TABULKU `NetworkAP`:
--   `NetworkDevice`
--       `NetworkDevice` -> `Id`
--

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

--
-- Struktura tabulky `NetworkConfiguration`
--

CREATE TABLE IF NOT EXISTS `NetworkConfiguration` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Caption` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Execute` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Changed` int(11) NOT NULL DEFAULT '0',
  `LastTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `ExecutionTime` int(11) NOT NULL,
  `Enabled` int(11) NOT NULL DEFAULT '1',
  `Period` int(11) NOT NULL DEFAULT '60',
  `Log` mediumtext COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=14 ;

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

--
-- Struktura tabulky `NetworkDevice`
--

CREATE TABLE IF NOT EXISTS `NetworkDevice` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Member` int(11) NOT NULL COMMENT 'Member',
  `Location` int(11) NOT NULL COMMENT 'Member',
  `Type` int(11) NOT NULL COMMENT 'NetworkDeviceType',
  `PositionLatitude` double NOT NULL DEFAULT '0',
  `PositionLongitude` double NOT NULL DEFAULT '0',
  `Used` int(11) NOT NULL DEFAULT '1',
  `Online` int(11) NOT NULL DEFAULT '0',
  `LastOnline` datetime NOT NULL,
  `PermanentOnline` int(11) NOT NULL DEFAULT '0',
  `InboundNATPriority` int(11) NOT NULL DEFAULT '1',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Name` (`Name`),
  KEY `Member` (`Member`),
  KEY `Location` (`Location`),
  KEY `Type` (`Type`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=639 ;

--
-- RELACE PRO TABULKU `NetworkDevice`:
--   `Member`
--       `Member` -> `Id`
--   `Location`
--       `Member` -> `Id`
--   `Type`
--       `NetworkDeviceType` -> `Id`
--

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

--
-- Struktura tabulky `NetworkDeviceConfig`
--

CREATE TABLE IF NOT EXISTS `NetworkDeviceConfig` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Device` int(11) NOT NULL,
  `Time` date NOT NULL,
  `ConfigFull` mediumtext NOT NULL,
  `ConfigCompact` mediumtext NOT NULL,
  PRIMARY KEY (`Id`),
  KEY `Time` (`Time`),
  KEY `Device` (`Device`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

--
-- RELACE PRO TABULKU `NetworkDeviceConfig`:
--   `Device`
--       `NetworkDevice` -> `Id`
--

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

--
-- Struktura tabulky `NetworkDeviceHistory`
--

CREATE TABLE IF NOT EXISTS `NetworkDeviceHistory` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Device` int(11) NOT NULL DEFAULT '0',
  `Time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `Action` int(11) NOT NULL DEFAULT '0',
  `Notice` varchar(255) COLLATE utf8_czech_ci NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`),
  KEY `Device` (`Device`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1 ;

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

--
-- Struktura tabulky `NetworkDeviceType`
--

CREATE TABLE IF NOT EXISTS `NetworkDeviceType` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `ShowOnline` int(11) NOT NULL DEFAULT '0',
  `IconName` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=11 ;

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

--
-- Struktura tabulky `NetworkDomainAlias`
--

CREATE TABLE IF NOT EXISTS `NetworkDomainAlias` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Target` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Comment` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Name` (`Name`,`Target`),
  UNIQUE KEY `Name_2` (`Name`,`Target`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=40 ;

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

--
-- Struktura tabulky `NetworkFirewall`
--

CREATE TABLE IF NOT EXISTS `NetworkFirewall` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `NetworkDevice` int(11) NOT NULL,
  `SourceInterface` varchar(255) COLLATE utf8_czech_ci DEFAULT NULL,
  `DestinationInterface` varchar(255) COLLATE utf8_czech_ci DEFAULT NULL,
  `SourceAddress` varchar(255) COLLATE utf8_czech_ci DEFAULT NULL,
  `DestinationAddress` varchar(255) COLLATE utf8_czech_ci DEFAULT NULL,
  `SourcePort` int(11) DEFAULT NULL,
  `DestinationPort` int(11) DEFAULT NULL,
  `Action` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Comment` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`Id`),
  KEY `NetworkDevice` (`NetworkDevice`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=8 ;

--
-- RELACE PRO TABULKU `NetworkFirewall`:
--   `NetworkDevice`
--       `NetworkDevice` -> `Id`
--

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

--
-- Struktura tabulky `NetworkInterface`
--

CREATE TABLE IF NOT EXISTS `NetworkInterface` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(16) COLLATE utf8_czech_ci NOT NULL,
  `Type` int(11) NOT NULL,
  `MAC` varchar(17) COLLATE utf8_czech_ci NOT NULL,
  `LocalIP` varchar(16) COLLATE utf8_czech_ci NOT NULL,
  `IPv6` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `ExternalIP` varchar(16) COLLATE utf8_czech_ci NOT NULL,
  `Device` int(11) NOT NULL,
  `Online` int(11) NOT NULL DEFAULT '0',
  `LastOnline` datetime NOT NULL,
  PRIMARY KEY (`Id`),
  KEY `Device` (`Device`),
  KEY `Type` (`Type`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=705 ;

--
-- RELACE PRO TABULKU `NetworkInterface`:
--   `Type`
--       `NetworkInterfaceType` -> `Id`
--   `Device`
--       `NetworkDevice` -> `Id`
--

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

--
-- Struktura tabulky `NetworkInterfacePortable`
--

CREATE TABLE IF NOT EXISTS `NetworkInterfacePortable` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `NetworkInterface` int(11) NOT NULL,
  `DynamicIP` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Time` datetime NOT NULL,
  `Update` int(11) NOT NULL,
  PRIMARY KEY (`Id`),
  KEY `NetworkInterface` (`NetworkInterface`),
  KEY `Update` (`Update`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1 ;

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

--
-- Struktura tabulky `NetworkInterfaceStat`
--

CREATE TABLE IF NOT EXISTS `NetworkInterfaceStat` (
  `NetworkInterface` int(11) NOT NULL DEFAULT '0',
  `Time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `PingCount` smallint(11) NOT NULL DEFAULT '0',
  KEY `host_id` (`NetworkInterface`),
  KEY `time` (`Time`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;

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

--
-- Struktura tabulky `NetworkInterfaceType`
--

CREATE TABLE IF NOT EXISTS `NetworkInterfaceType` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `MaxSpeed` int(11) NOT NULL,
  `FullDuplex` int(11) NOT NULL DEFAULT '1',
  `Color` varchar(6) COLLATE utf8_czech_ci NOT NULL DEFAULT 'ffffff',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=8 ;

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

--
-- Struktura tabulky `NetworkLink`
--

CREATE TABLE IF NOT EXISTS `NetworkLink` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Type` int(11) NOT NULL,
  `Interface1` int(11) NOT NULL,
  `Interface2` int(11) NOT NULL,
  PRIMARY KEY (`Id`),
  KEY `Interface1` (`Interface1`),
  KEY `Interface2` (`Interface2`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=356 ;

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

--
-- Struktura tabulky `NetworkMangleSubgroup`
--

CREATE TABLE IF NOT EXISTS `NetworkMangleSubgroup` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `AddressRange` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`Id`),
  KEY `AddressRange` (`AddressRange`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=147 ;

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

--
-- Struktura tabulky `NetworkMark`
--

CREATE TABLE IF NOT EXISTS `NetworkMark` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Comment` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`Id`),
  KEY `Comment` (`Comment`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1404 ;

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

--
-- Struktura tabulky `NetworkSegment`
--

CREATE TABLE IF NOT EXISTS `NetworkSegment` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(128) COLLATE utf8_czech_ci NOT NULL,
  `Price` int(11) NOT NULL DEFAULT '0',
  `Parent` int(11) DEFAULT '0',
  `Users` int(11) NOT NULL DEFAULT '0',
  `Consumption` int(11) NOT NULL DEFAULT '0',
  `UsersOverheads` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`Id`),
  KEY `Parent` (`Parent`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=33 ;

--
-- RELACE PRO TABULKU `NetworkSegment`:
--   `Parent`
--       `NetworkSegment` -> `Id`
--

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

--
-- Struktura tabulky `NetworkSubnet`
--

CREATE TABLE IF NOT EXISTS `NetworkSubnet` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `AddressRange` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Mask` int(11) NOT NULL,
  `DHCP` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Gateway` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `WINS` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `DNS` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Domain` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `NTP` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Member` int(11) DEFAULT NULL,
  `ExtAddressRange` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `ExtMask` int(11) NOT NULL DEFAULT '32',
  `AddressRangeIPv6` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Configure` int(11) NOT NULL DEFAULT '1',
  PRIMARY KEY (`Id`),
  KEY `Member` (`Member`),
  KEY `Configure` (`Configure`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=44 ;

--
-- RELACE PRO TABULKU `NetworkSubnet`:
--   `Member`
--       `Member` -> `Id`
--

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

--
-- Struktura tabulky `NetworkTopology`
--

CREATE TABLE IF NOT EXISTS `NetworkTopology` (
  `Host` int(11) NOT NULL DEFAULT '0',
  `Depth` int(11) NOT NULL DEFAULT '0',
  `Pos` int(11) NOT NULL DEFAULT '0',
  `First` int(11) NOT NULL DEFAULT '0',
  `Last` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`Host`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;

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

--
-- Struktura tabulky `News`
--

CREATE TABLE IF NOT EXISTS `News` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Title` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Content` text COLLATE utf8_czech_ci NOT NULL,
  `Date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `TargetDate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `Author` varchar(32) COLLATE utf8_czech_ci NOT NULL,
  `IP` varchar(16) COLLATE utf8_czech_ci NOT NULL,
  `Category` int(11) DEFAULT '0',
  `Enclosure` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `User` int(11) DEFAULT NULL,
  `Link` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`Id`),
  KEY `category` (`Category`),
  KEY `date` (`Date`),
  KEY `Title` (`Title`),
  KEY `Link` (`Link`),
  KEY `User` (`User`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=973267 ;

--
-- RELACE PRO TABULKU `News`:
--   `Category`
--       `NewsCategory` -> `Id`
--   `User`
--       `User` -> `Id`
--

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

--
-- Struktura tabulky `NewsCategory`
--

CREATE TABLE IF NOT EXISTS `NewsCategory` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Caption` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Permission` int(11) NOT NULL DEFAULT '0',
  `Sequence` int(11) NOT NULL,
  `Group` int(11) NOT NULL DEFAULT '1',
  `RSS` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`Id`),
  KEY `Sequence` (`Sequence`),
  KEY `Group` (`Group`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=17 ;

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

--
-- Struktura tabulky `Panel`
--

CREATE TABLE IF NOT EXISTS `Panel` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Module` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Parameters` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Order` int(11) NOT NULL,
  `PanelColumn` int(11) NOT NULL,
  PRIMARY KEY (`Id`),
  KEY `PanelColumn` (`PanelColumn`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=14 ;

--
-- RELACE PRO TABULKU `Panel`:
--   `PanelColumn`
--       `PanelColumn` -> `Id`
--

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

--
-- Struktura tabulky `PanelColumn`
--

CREATE TABLE IF NOT EXISTS `PanelColumn` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Width` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=4 ;

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

--
-- Struktura tabulky `PermissionGroup`
--

CREATE TABLE IF NOT EXISTS `PermissionGroup` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Description` varchar(255) COLLATE utf8_czech_ci NOT NULL DEFAULT '',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=6 ;

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

--
-- Struktura tabulky `PermissionGroupAssignment`
--

CREATE TABLE IF NOT EXISTS `PermissionGroupAssignment` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Group` int(11) NOT NULL DEFAULT '0',
  `AssignedGroup` int(11) DEFAULT NULL,
  `AssignedOperation` int(11) DEFAULT NULL,
  PRIMARY KEY (`Id`),
  KEY `Group` (`Group`),
  KEY `AssignedGroup` (`AssignedGroup`),
  KEY `AssignedOperation` (`AssignedOperation`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=48 ;

--
-- RELACE PRO TABULKU `PermissionGroupAssignment`:
--   `Group`
--       `PermissionGroup` -> `Id`
--   `AssignedGroup`
--       `PermissionGroup` -> `Id`
--   `AssignedOperation`
--       `PermissionOperation` -> `Id`
--

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

--
-- Struktura tabulky `PermissionOperation`
--

CREATE TABLE IF NOT EXISTS `PermissionOperation` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Module` varchar(64) COLLATE utf8_czech_ci NOT NULL DEFAULT '',
  `Operation` varchar(128) COLLATE utf8_czech_ci NOT NULL DEFAULT '',
  `Item` varchar(64) COLLATE utf8_czech_ci NOT NULL DEFAULT '',
  `ItemId` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`Id`),
  KEY `Module` (`Module`),
  KEY `Operation` (`Operation`),
  KEY `Item` (`Item`),
  KEY `ItemId` (`ItemId`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=45 ;

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

--
-- Struktura tabulky `PermissionUserAssignment`
--

CREATE TABLE IF NOT EXISTS `PermissionUserAssignment` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `User` int(11) NOT NULL DEFAULT '0',
  `AssignedGroup` int(11) DEFAULT NULL,
  `AssignedOperation` int(11) DEFAULT NULL,
  PRIMARY KEY (`Id`),
  KEY `User` (`User`),
  KEY `AssignedGroup` (`AssignedGroup`),
  KEY `AssignedOperation` (`AssignedOperation`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=225 ;

--
-- RELACE PRO TABULKU `PermissionUserAssignment`:
--   `User`
--       `User` -> `Id`
--   `AssignedGroup`
--       `PermissionGroup` -> `Id`
--   `AssignedOperation`
--       `PermissionOperation` -> `Id`
--

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

--
-- Struktura tabulky `PhoneBook`
--

CREATE TABLE IF NOT EXISTS `PhoneBook` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Number` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Address` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `LastUpdate` datetime NOT NULL,
  `Operator` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=53 ;

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

--
-- Struktura tabulky `Product`
--

CREATE TABLE IF NOT EXISTS `Product` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `SellPrice` float NOT NULL,
  `BuyPrice` float NOT NULL,
  `VAT` float DEFAULT NULL,
  `Consumption` int(11) DEFAULT NULL COMMENT 'In Watts',
  `Supplier` int(11) DEFAULT NULL COMMENT 'Subject',
  `Manufacturer` int(11) DEFAULT NULL,
  `Code` varchar(255) COLLATE utf8_czech_ci DEFAULT NULL,
  `UnitOfMeasure` int(11) NOT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Code` (`Code`),
  KEY `Supplier` (`Supplier`),
  KEY `UnitOfMeasure` (`UnitOfMeasure`),
  KEY `Manufacturer` (`Manufacturer`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=166 ;

--
-- RELACE PRO TABULKU `Product`:
--   `Supplier`
--       `Subject` -> `Id`
--   `Manufacturer`
--       `Subject` -> `Id`
--   `UnitOfMeasure`
--       `UnitOfMeasure` -> `Id`
--

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

--
-- Struktura tabulky `ProductOld`
--

CREATE TABLE IF NOT EXISTS `ProductOld` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(128) COLLATE utf8_czech_ci NOT NULL,
  `Price` int(11) NOT NULL DEFAULT '0',
  `Count` int(11) NOT NULL DEFAULT '1',
  `Date` date NOT NULL DEFAULT '0000-00-00',
  `Segment` int(11) DEFAULT '0',
  `Used` int(11) NOT NULL DEFAULT '0',
  `Consumption` int(11) NOT NULL DEFAULT '0',
  `User` int(11) DEFAULT '0',
  `Info` text COLLATE utf8_czech_ci NOT NULL,
  `Channel` int(11) NOT NULL DEFAULT '0',
  `DeviceId` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Shop` varchar(64) COLLATE utf8_czech_ci NOT NULL,
  `DeprecatedPrice` int(11) NOT NULL DEFAULT '0',
  `TimeEnlistment` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `TimeElimination` datetime DEFAULT '0000-00-00 00:00:00',
  `StockCard` int(11) NOT NULL,
  PRIMARY KEY (`Id`),
  KEY `Segment` (`Segment`),
  KEY `Used` (`Used`),
  KEY `User` (`User`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=164 ;

--
-- RELACE PRO TABULKU `ProductOld`:
--   `Segment`
--       `NetworkSegment` -> `Id`
--

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

--
-- Struktura tabulky `Service`
--

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

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

--
-- Struktura tabulky `Stock`
--

CREATE TABLE IF NOT EXISTS `Stock` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Location` int(11) DEFAULT NULL,
  PRIMARY KEY (`Id`),
  KEY `Location` (`Location`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=4 ;

--
-- RELACE PRO TABULKU `Stock`:
--   `Location`
--       `Member` -> `Id`
--

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

--
-- Struktura tabulky `StockItem`
--

CREATE TABLE IF NOT EXISTS `StockItem` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Stock` int(11) NOT NULL,
  `Product` int(11) NOT NULL,
  `TimeEnlistment` date NOT NULL,
  `TimeElimination` date DEFAULT NULL,
  `BuyPrice` decimal(10,0) NOT NULL,
  `SellPrice` decimal(10,0) NOT NULL,
  `Amount` float NOT NULL,
  `SerialNumber` varchar(255) COLLATE utf8_czech_ci DEFAULT NULL,
  `Location` int(11) DEFAULT NULL COMMENT 'Member',
  `Segment` int(11) DEFAULT NULL,
  `Info` text COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `SerialNumber` (`SerialNumber`),
  KEY `Product` (`Product`),
  KEY `Stock` (`Stock`),
  KEY `Segment` (`Segment`),
  KEY `Location` (`Location`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=164 ;

--
-- RELACE PRO TABULKU `StockItem`:
--   `Location`
--       `Member` -> `Id`
--   `Stock`
--       `Stock` -> `Id`
--   `StockCard`
--       `StockCard` -> `Id`
--   `Product`
--       `Product` -> `Id`
--   `Segment`
--       `NetworkSegment` -> `Id`
--

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

--
-- Struktura tabulky `Subject`
--

CREATE TABLE IF NOT EXISTS `Subject` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(64) COLLATE utf8_czech_ci NOT NULL DEFAULT '',
  `AddressStreet` varchar(64) COLLATE utf8_czech_ci NOT NULL DEFAULT '',
  `AddressTown` varchar(64) COLLATE utf8_czech_ci NOT NULL DEFAULT '',
  `AddressPSC` int(11) NOT NULL DEFAULT '0',
  `AddressCountry` int(11) NOT NULL,
  `IC` varchar(32) COLLATE utf8_czech_ci NOT NULL,
  `DIC` varchar(32) COLLATE utf8_czech_ci NOT NULL DEFAULT '',
  `MapPositionX` float NOT NULL DEFAULT '0',
  `MapPositionY` float NOT NULL DEFAULT '0',
  `WWW` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Note` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`Id`),
  KEY `AddressCountry` (`AddressCountry`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=229 ;

--
-- RELACE PRO TABULKU `Subject`:
--   `AddressCountry`
--       `Country` -> `Id`
--

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

--
-- Struktura tabulky `SubjectOpenTime`
--

CREATE TABLE IF NOT EXISTS `SubjectOpenTime` (
  `Subject` int(11) NOT NULL DEFAULT '0',
  `UpdateTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `Notice` varchar(255) COLLATE utf8_czech_ci NOT NULL DEFAULT '',
  `Photo` int(11) NOT NULL,
  KEY `Subject` (`Subject`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;

--
-- RELACE PRO TABULKU `SubjectOpenTime`:
--   `Subject`
--       `Subject` -> `Id`
--

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

--
-- Struktura tabulky `SubjectOpenTimeDay`
--

CREATE TABLE IF NOT EXISTS `SubjectOpenTimeDay` (
  `Subject` int(11) NOT NULL,
  `Day` int(11) NOT NULL,
  `Open1` int(11) NOT NULL,
  `Close1` int(11) NOT NULL,
  `Open2` int(11) NOT NULL,
  `Close2` int(11) NOT NULL,
  KEY `Subject` (`Subject`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;

--
-- RELACE PRO TABULKU `SubjectOpenTimeDay`:
--   `Subject`
--       `Subject` -> `Id`
--

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

--
-- Struktura tabulky `SystemVersion`
--

CREATE TABLE IF NOT EXISTS `SystemVersion` (
  `Rev464` bit(1) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

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

--
-- Struktura tabulky `Task`
--

CREATE TABLE IF NOT EXISTS `Task` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Description` text COLLATE utf8_czech_ci NOT NULL,
  `TimeCreate` date NOT NULL,
  `TimeDue` date DEFAULT NULL,
  `TimeClose` date DEFAULT NULL,
  `Priority` int(11) NOT NULL,
  `Conclusion` text COLLATE utf8_czech_ci NOT NULL,
  `Public` int(11) NOT NULL,
  `Progress` int(11) NOT NULL,
  `Group` int(11) DEFAULT NULL,
  `AssignedTo` int(11) DEFAULT NULL,
  PRIMARY KEY (`Id`),
  KEY `Group` (`Group`),
  KEY `AssignedTo` (`AssignedTo`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=7 ;

--
-- RELACE PRO TABULKU `Task`:
--   `Group`
--       `TaskGroup` -> `Id`
--   `AssignedTo`
--       `User` -> `Id`
--

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

--
-- Struktura tabulky `TaskGroup`
--

CREATE TABLE IF NOT EXISTS `TaskGroup` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Description` text COLLATE utf8_czech_ci NOT NULL,
  `Parent` int(11) DEFAULT NULL,
  PRIMARY KEY (`Id`),
  KEY `Parent` (`Parent`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=3 ;

--
-- RELACE PRO TABULKU `TaskGroup`:
--   `Parent`
--       `TaskGroup` -> `Id`
--

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

--
-- Struktura tabulky `TV`
--

CREATE TABLE IF NOT EXISTS `TV` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(16) COLLATE utf8_czech_ci NOT NULL,
  `Frequency` int(11) NOT NULL DEFAULT '0',
  `Norm` varchar(8) COLLATE utf8_czech_ci NOT NULL,
  `Homepage` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Language` int(11) DEFAULT NULL,
  `ShortName` varchar(16) COLLATE utf8_czech_ci NOT NULL,
  `Stream` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `StreamWeb` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `SourceType` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Category` int(11) DEFAULT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `ShortName` (`ShortName`),
  KEY `Language` (`Language`),
  KEY `Category` (`Category`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=46 ;

--
-- RELACE PRO TABULKU `TV`:
--   `Language`
--       `Language` -> `Id`
--   `Category`
--       `TVGroup` -> `Id`
--

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

--
-- Struktura tabulky `TVGroup`
--

CREATE TABLE IF NOT EXISTS `TVGroup` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=7 ;

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

--
-- Struktura tabulky `UnitOfMeasure`
--

CREATE TABLE IF NOT EXISTS `UnitOfMeasure` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Unit` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=11 ;

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

--
-- Struktura tabulky `User`
--

CREATE TABLE IF NOT EXISTS `User` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Login` varchar(64) COLLATE utf8_czech_ci NOT NULL,
  `Name` varchar(128) COLLATE utf8_czech_ci NOT NULL,
  `Password` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Salt` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `Email` varchar(128) COLLATE utf8_czech_ci NOT NULL DEFAULT '',
  `LastIpAddress` varchar(16) COLLATE utf8_czech_ci NOT NULL DEFAULT '',
  `LastLoginTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `RegistrationTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `Locked` tinyint(1) NOT NULL DEFAULT '0',
  `ICQ` int(11) NOT NULL DEFAULT '0',
  `PhoneNumber` varchar(32) COLLATE utf8_czech_ci NOT NULL DEFAULT '',
  `InitPassword` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Name` (`Login`),
  UNIQUE KEY `Nick` (`Name`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=250 ;

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

--
-- Struktura tabulky `UserCustomerRel`
--

CREATE TABLE IF NOT EXISTS `UserCustomerRel` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Customer` int(11) NOT NULL,
  `User` int(11) NOT NULL,
  PRIMARY KEY (`Id`),
  KEY `Customer` (`Customer`),
  KEY `User` (`User`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=519 ;

--
-- RELACE PRO TABULKU `UserCustomerRel`:
--   `Customer`
--       `Member` -> `Id`
--   `User`
--       `User` -> `Id`
--

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

--
-- Struktura tabulky `UserOnline`
--

CREATE TABLE IF NOT EXISTS `UserOnline` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `User` int(11) NOT NULL DEFAULT '0' COMMENT 'User.Id',
  `ActivityTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `LoginTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `SessionId` varchar(255) COLLATE utf8_czech_ci NOT NULL DEFAULT '',
  `IpAddress` varchar(16) COLLATE utf8_czech_ci NOT NULL DEFAULT '',
  `HostName` varchar(255) COLLATE utf8_czech_ci NOT NULL DEFAULT '',
  `ScriptName` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`Id`),
  KEY `User` (`User`)
) ENGINE=MEMORY  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=6761 ;

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

--
-- Struktura tabulky `Work`
--

CREATE TABLE IF NOT EXISTS `Work` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) NOT NULL,
  `Description` text,
  `TimeStart` datetime NOT NULL,
  `Duration` float NOT NULL,
  `User` int(11) DEFAULT NULL,
  `Task` int(11) DEFAULT NULL,
  PRIMARY KEY (`Id`),
  KEY `User` (`User`),
  KEY `Task` (`Task`),
  KEY `TimeStart` (`TimeStart`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

--
-- RELACE PRO TABULKU `Work`:
--   `User`
--       `User` -> `Id`
--   `Task`
--       `Task` -> `Id`
--

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

--
-- Omezení pro tabulku `DocumentLineSequence`
--
ALTER TABLE `DocumentLineSequence`
  ADD CONSTRAINT `DocumentLineSequence_ibfk_1` FOREIGN KEY (`DocumentLine`) REFERENCES `DocumentLine` (`Id`),
  ADD CONSTRAINT `DocumentLineSequence_ibfk_2` FOREIGN KEY (`FinanceYear`) REFERENCES `FinanceYear` (`Id`);

--
-- Omezení pro tabulku `FinanceBills`
--
ALTER TABLE `FinanceBills`
  ADD CONSTRAINT `FinanceBills_ibfk_1` FOREIGN KEY (`Subject`) REFERENCES `Subject` (`Id`);

--
-- Omezení pro tabulku `FinanceBillsItems`
--
ALTER TABLE `FinanceBillsItems`
  ADD CONSTRAINT `FinanceBillsItems_ibfk_1` FOREIGN KEY (`Bill`) REFERENCES `FinanceBills` (`Id`);

--
-- Omezení pro tabulku `FinanceClaimsLiabilities`
--
ALTER TABLE `FinanceClaimsLiabilities`
  ADD CONSTRAINT `FinanceClaimsLiabilities_ibfk_1` FOREIGN KEY (`Subject`) REFERENCES `Subject` (`Id`);

--
-- Omezení pro tabulku `FinanceOperation`
--
ALTER TABLE `FinanceOperation`
  ADD CONSTRAINT `FinanceOperation_ibfk_1` FOREIGN KEY (`Subject`) REFERENCES `Subject` (`Id`),
  ADD CONSTRAINT `FinanceOperation_ibfk_2` FOREIGN KEY (`Bill`) REFERENCES `FinanceBills` (`Id`),
  ADD CONSTRAINT `FinanceOperation_ibfk_3` FOREIGN KEY (`BankAccount`) REFERENCES `FinanceBankAccount` (`Id`),
  ADD CONSTRAINT `FinanceOperation_ibfk_4` FOREIGN KEY (`Treasury`) REFERENCES `FinanceTreasury` (`Id`);

--
-- Omezení pro tabulku `Hyperlink`
--
ALTER TABLE `Hyperlink`
  ADD CONSTRAINT `Hyperlink_ibfk_1` FOREIGN KEY (`Group`) REFERENCES `HyperlinkGroup` (`Id`);

--
-- Omezení pro tabulku `ISMenuItem`
--
ALTER TABLE `ISMenuItem`
  ADD CONSTRAINT `ISMenuItem_ibfk_1` FOREIGN KEY (`Parent`) REFERENCES `ISMenuItem` (`Id`);

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

--
-- Omezení pro tabulku `Member`
--
ALTER TABLE `Member`
  ADD CONSTRAINT `Member_ibfk_23` FOREIGN KEY (`Subject`) REFERENCES `Subject` (`Id`),
  ADD CONSTRAINT `Member_ibfk_24` FOREIGN KEY (`ResponsibleUser`) REFERENCES `User` (`Id`),
  ADD CONSTRAINT `Member_ibfk_25` FOREIGN KEY (`InternetTariffCurrentMonth`) REFERENCES `FinanceTariff` (`Id`),
  ADD CONSTRAINT `Member_ibfk_26` FOREIGN KEY (`InternetTariffNextMonth`) REFERENCES `FinanceTariff` (`Id`),
  ADD CONSTRAINT `Member_ibfk_27` FOREIGN KEY (`BillingPeriod`) REFERENCES `FinanceBillingPeriod` (`Id`),
  ADD CONSTRAINT `Member_ibfk_28` FOREIGN KEY (`BillingPeriodNext`) REFERENCES `FinanceBillingPeriod` (`Id`);

--
-- Omezení pro tabulku `MemberPayment`
--
ALTER TABLE `MemberPayment`
  ADD CONSTRAINT `MemberPayment_ibfk_1` FOREIGN KEY (`Member`) REFERENCES `Member` (`Id`);

--
-- Omezení pro tabulku `NetworkAP`
--
ALTER TABLE `NetworkAP`
  ADD CONSTRAINT `NetworkAP_ibfk_1` FOREIGN KEY (`NetworkDevice`) REFERENCES `NetworkDevice` (`Id`);

--
-- Omezení pro tabulku `NetworkDevice`
--
ALTER TABLE `NetworkDevice`
  ADD CONSTRAINT `NetworkDevice_ibfk_4` FOREIGN KEY (`Member`) REFERENCES `Member` (`Id`),
  ADD CONSTRAINT `NetworkDevice_ibfk_5` FOREIGN KEY (`Location`) REFERENCES `Member` (`Id`),
  ADD CONSTRAINT `NetworkDevice_ibfk_6` FOREIGN KEY (`Type`) REFERENCES `NetworkDeviceType` (`Id`);

--
-- Omezení pro tabulku `NetworkDeviceConfig`
--
ALTER TABLE `NetworkDeviceConfig`
  ADD CONSTRAINT `NetworkDeviceConfig_ibfk_1` FOREIGN KEY (`Device`) REFERENCES `NetworkDevice` (`Id`);

--
-- Omezení pro tabulku `NetworkFirewall`
--
ALTER TABLE `NetworkFirewall`
  ADD CONSTRAINT `NetworkFirewall_ibfk_1` FOREIGN KEY (`NetworkDevice`) REFERENCES `NetworkDevice` (`Id`);

--
-- Omezení pro tabulku `NetworkInterface`
--
ALTER TABLE `NetworkInterface`
  ADD CONSTRAINT `NetworkInterface_ibfk_1` FOREIGN KEY (`Type`) REFERENCES `NetworkInterfaceType` (`Id`),
  ADD CONSTRAINT `NetworkInterface_ibfk_2` FOREIGN KEY (`Device`) REFERENCES `NetworkDevice` (`Id`);

--
-- Omezení pro tabulku `NetworkSegment`
--
ALTER TABLE `NetworkSegment`
  ADD CONSTRAINT `NetworkSegment_ibfk_1` FOREIGN KEY (`Parent`) REFERENCES `NetworkSegment` (`Id`);

--
-- Omezení pro tabulku `NetworkSubnet`
--
ALTER TABLE `NetworkSubnet`
  ADD CONSTRAINT `NetworkSubnet_ibfk_1` FOREIGN KEY (`Member`) REFERENCES `Member` (`Id`);

--
-- Omezení pro tabulku `News`
--
ALTER TABLE `News`
  ADD CONSTRAINT `News_ibfk_1` FOREIGN KEY (`Category`) REFERENCES `NewsCategory` (`Id`),
  ADD CONSTRAINT `News_ibfk_2` FOREIGN KEY (`User`) REFERENCES `User` (`Id`);

--
-- Omezení pro tabulku `Panel`
--
ALTER TABLE `Panel`
  ADD CONSTRAINT `Panel_ibfk_1` FOREIGN KEY (`PanelColumn`) REFERENCES `PanelColumn` (`Id`);

--
-- Omezení pro tabulku `PermissionGroupAssignment`
--
ALTER TABLE `PermissionGroupAssignment`
  ADD CONSTRAINT `PermissionGroupAssignment_ibfk_1` FOREIGN KEY (`Group`) REFERENCES `PermissionGroup` (`Id`),
  ADD CONSTRAINT `PermissionGroupAssignment_ibfk_2` FOREIGN KEY (`AssignedGroup`) REFERENCES `PermissionGroup` (`Id`),
  ADD CONSTRAINT `PermissionGroupAssignment_ibfk_3` FOREIGN KEY (`AssignedOperation`) REFERENCES `PermissionOperation` (`Id`);

--
-- Omezení pro tabulku `PermissionUserAssignment`
--
ALTER TABLE `PermissionUserAssignment`
  ADD CONSTRAINT `PermissionUserAssignment_ibfk_1` FOREIGN KEY (`User`) REFERENCES `User` (`Id`),
  ADD CONSTRAINT `PermissionUserAssignment_ibfk_2` FOREIGN KEY (`AssignedGroup`) REFERENCES `PermissionGroup` (`Id`),
  ADD CONSTRAINT `PermissionUserAssignment_ibfk_3` FOREIGN KEY (`AssignedOperation`) REFERENCES `PermissionOperation` (`Id`);

--
-- Omezení pro tabulku `Product`
--
ALTER TABLE `Product`
  ADD CONSTRAINT `Product_ibfk_1` FOREIGN KEY (`Supplier`) REFERENCES `Subject` (`Id`),
  ADD CONSTRAINT `Product_ibfk_2` FOREIGN KEY (`Manufacturer`) REFERENCES `Subject` (`Id`),
  ADD CONSTRAINT `Product_ibfk_3` FOREIGN KEY (`UnitOfMeasure`) REFERENCES `UnitOfMeasure` (`Id`);

--
-- Omezení pro tabulku `ProductOld`
--
ALTER TABLE `ProductOld`
  ADD CONSTRAINT `ProductOld_ibfk_1` FOREIGN KEY (`Segment`) REFERENCES `NetworkSegment` (`Id`);

--
-- Omezení pro tabulku `Stock`
--
ALTER TABLE `Stock`
  ADD CONSTRAINT `Stock_ibfk_1` FOREIGN KEY (`Location`) REFERENCES `Member` (`Id`);

--
-- Omezení pro tabulku `StockItem`
--
ALTER TABLE `StockItem`
  ADD CONSTRAINT `StockItem_ibfk_1` FOREIGN KEY (`Stock`) REFERENCES `Stock` (`Id`),
  ADD CONSTRAINT `StockItem_ibfk_3` FOREIGN KEY (`Location`) REFERENCES `Member` (`Id`),
  ADD CONSTRAINT `StockItem_ibfk_5` FOREIGN KEY (`Product`) REFERENCES `Product` (`Id`),
  ADD CONSTRAINT `StockItem_ibfk_6` FOREIGN KEY (`Segment`) REFERENCES `NetworkSegment` (`Id`);

--
-- Omezení pro tabulku `Subject`
--
ALTER TABLE `Subject`
  ADD CONSTRAINT `Subject_ibfk_1` FOREIGN KEY (`AddressCountry`) REFERENCES `Country` (`Id`);

--
-- Omezení pro tabulku `SubjectOpenTime`
--
ALTER TABLE `SubjectOpenTime`
  ADD CONSTRAINT `SubjectOpenTime_ibfk_1` FOREIGN KEY (`Subject`) REFERENCES `Subject` (`Id`);

--
-- Omezení pro tabulku `SubjectOpenTimeDay`
--
ALTER TABLE `SubjectOpenTimeDay`
  ADD CONSTRAINT `SubjectOpenTimeDay_ibfk_1` FOREIGN KEY (`Subject`) REFERENCES `Subject` (`Id`);

--
-- Omezení pro tabulku `Task`
--
ALTER TABLE `Task`
  ADD CONSTRAINT `Task_ibfk_1` FOREIGN KEY (`Group`) REFERENCES `TaskGroup` (`Id`),
  ADD CONSTRAINT `Task_ibfk_2` FOREIGN KEY (`AssignedTo`) REFERENCES `User` (`Id`);

--
-- Omezení pro tabulku `TaskGroup`
--
ALTER TABLE `TaskGroup`
  ADD CONSTRAINT `TaskGroup_ibfk_1` FOREIGN KEY (`Parent`) REFERENCES `TaskGroup` (`Id`);

--
-- Omezení pro tabulku `TV`
--
ALTER TABLE `TV`
  ADD CONSTRAINT `TV_ibfk_1` FOREIGN KEY (`Language`) REFERENCES `Language` (`Id`),
  ADD CONSTRAINT `TV_ibfk_2` FOREIGN KEY (`Category`) REFERENCES `TVGroup` (`Id`);

--
-- Omezení pro tabulku `UserCustomerRel`
--
ALTER TABLE `UserCustomerRel`
  ADD CONSTRAINT `usercustomerrel_ibfk_1` FOREIGN KEY (`Customer`) REFERENCES `Member` (`Id`),
  ADD CONSTRAINT `usercustomerrel_ibfk_2` FOREIGN KEY (`User`) REFERENCES `User` (`Id`);

--
-- Omezení pro tabulku `Work`
--
ALTER TABLE `Work`
  ADD CONSTRAINT `Work_ibfk_1` FOREIGN KEY (`User`) REFERENCES `User` (`Id`),
  ADD CONSTRAINT `Work_ibfk_2` FOREIGN KEY (`Task`) REFERENCES `Task` (`Id`);
