-- phpMyAdmin SQL Dump
-- version 3.5.2.2
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Erstellungszeit: 10. Jul 2013 um 13:57
-- Server Version: 5.5.27
-- PHP-Version: 5.4.7

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


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Datenbank: `geodb`
--

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

--
-- Tabellenstruktur für Tabelle `domain`
--
-- Erzeugt am: 23. Mai 2013 um 09:08
--

DROP TABLE IF EXISTS `domain`;
CREATE TABLE IF NOT EXISTS `domain` (
  `id` int(32) NOT NULL AUTO_INCREMENT,
  `name` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=4 ;

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

--
-- Tabellenstruktur für Tabelle `information`
--
-- Erzeugt am: 23. Mai 2013 um 08:57
--

DROP TABLE IF EXISTS `information`;
CREATE TABLE IF NOT EXISTS `information` (
  `id` int(32) NOT NULL AUTO_INCREMENT,
  `name` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=5 ;

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

--
-- Stellvertreter-Struktur des Views `pis`
--
DROP VIEW IF EXISTS `pis`;
CREATE TABLE IF NOT EXISTS `pis` (
`pid` int(32)
,`iid` int(32)
,`iName` varchar(50)
,`iValue` varchar(500)
);
-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `place`
--
-- Erzeugt am: 23. Mai 2013 um 08:41
--

DROP TABLE IF EXISTS `place`;
CREATE TABLE IF NOT EXISTS `place` (
  `id` int(32) NOT NULL AUTO_INCREMENT,
  `plan` geometry NOT NULL,
  `parent` int(32) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=183190823 ;

--
-- RELATIONEN DER TABELLE `place`:
--   `parent`
--       `place` -> `id`
--

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

--
-- Tabellenstruktur für Tabelle `placealias`
--
-- Erzeugt am: 23. Mai 2013 um 09:11
--

DROP TABLE IF EXISTS `placealias`;
CREATE TABLE IF NOT EXISTS `placealias` (
  `aid` int(32) NOT NULL AUTO_INCREMENT,
  `pid` int(32) NOT NULL,
  `alias` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`aid`,`pid`),
  KEY `pid` (`pid`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=172 ;

--
-- RELATIONEN DER TABELLE `placealias`:
--   `pid`
--       `place` -> `id`
--

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

--
-- Stellvertreter-Struktur des Views `placealiasview`
--
DROP VIEW IF EXISTS `placealiasview`;
CREATE TABLE IF NOT EXISTS `placealiasview` (
`alias` varchar(250)
,`plan` geometry
,`aid` int(32)
,`pid` int(32)
,`parent` int(32)
);
-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `placedomain`
--
-- Erzeugt am: 23. Mai 2013 um 09:22
--

DROP TABLE IF EXISTS `placedomain`;
CREATE TABLE IF NOT EXISTS `placedomain` (
  `pid` int(32) NOT NULL,
  `did` int(32) NOT NULL,
  PRIMARY KEY (`pid`,`did`),
  KEY `did` (`did`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- RELATIONEN DER TABELLE `placedomain`:
--   `pid`
--       `place` -> `id`
--   `did`
--       `domain` -> `id`
--

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

--
-- Stellvertreter-Struktur des Views `placedomainview`
--
DROP VIEW IF EXISTS `placedomainview`;
CREATE TABLE IF NOT EXISTS `placedomainview` (
`pid` int(32)
,`did` int(32)
,`name` varchar(50)
);
-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `placeinformation`
--
-- Erzeugt am: 23. Mai 2013 um 09:16
--

DROP TABLE IF EXISTS `placeinformation`;
CREATE TABLE IF NOT EXISTS `placeinformation` (
  `pid` int(32) NOT NULL,
  `iid` int(32) NOT NULL,
  `value` varchar(500) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`pid`,`iid`),
  KEY `iid` (`iid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- RELATIONEN DER TABELLE `placeinformation`:
--   `pid`
--       `place` -> `id`
--   `iid`
--       `information` -> `id`
--

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

--
-- Stellvertreter-Struktur des Views `placeinformationview`
--
DROP VIEW IF EXISTS `placeinformationview`;
CREATE TABLE IF NOT EXISTS `placeinformationview` (
`pid` int(32)
,`iid` int(32)
,`name` varchar(50)
,`value` varchar(500)
);
-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `placeservice`
--
-- Erzeugt am: 23. Mai 2013 um 09:20
--

DROP TABLE IF EXISTS `placeservice`;
CREATE TABLE IF NOT EXISTS `placeservice` (
  `pid` int(32) NOT NULL,
  `sid` int(32) NOT NULL,
  `request` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`pid`,`sid`),
  KEY `sid` (`sid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- RELATIONEN DER TABELLE `placeservice`:
--   `pid`
--       `place` -> `id`
--   `sid`
--       `service` -> `id`
--

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

--
-- Stellvertreter-Struktur des Views `placeserviceview`
--
DROP VIEW IF EXISTS `placeserviceview`;
CREATE TABLE IF NOT EXISTS `placeserviceview` (
`pid` int(32)
,`sid` int(32)
,`name` varchar(50)
,`sap` varchar(250)
,`request` varchar(250)
);
-- --------------------------------------------------------

--
-- Stellvertreter-Struktur des Views `pss`
--
DROP VIEW IF EXISTS `pss`;
CREATE TABLE IF NOT EXISTS `pss` (
`pid` int(32)
,`sid` int(32)
,`sName` varchar(50)
,`sap` varchar(250)
,`request` varchar(250)
);
-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `service`
--
-- Erzeugt am: 23. Mai 2013 um 08:48
--

DROP TABLE IF EXISTS `service`;
CREATE TABLE IF NOT EXISTS `service` (
  `id` int(32) NOT NULL AUTO_INCREMENT,
  `name` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
  `sap` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=2 ;

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

--
-- Stellvertreter-Struktur des Views `sps`
--
DROP VIEW IF EXISTS `sps`;
CREATE TABLE IF NOT EXISTS `sps` (
`id` int(32)
,`plan` geometry
,`refpoint` mediumtext
,`parent` int(32)
,`did` int(32)
,`dName` varchar(50)
,`aid` int(32)
,`alias` varchar(250)
);
-- --------------------------------------------------------

--
-- Struktur des Views `pis`
--
DROP TABLE IF EXISTS `pis`;

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `pis` AS select `placeinformation`.`pid` AS `pid`,`placeinformation`.`iid` AS `iid`,`information`.`name` AS `iName`,`placeinformation`.`value` AS `iValue` from ((`placeinformation` left join `place` on((`place`.`id` = `placeinformation`.`pid`))) left join `information` on((`information`.`id` = `placeinformation`.`iid`)));

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

--
-- Struktur des Views `placealiasview`
--
DROP TABLE IF EXISTS `placealiasview`;

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `placealiasview` AS select `placealias`.`alias` AS `alias`,`place`.`plan` AS `plan`,`placealias`.`aid` AS `aid`,`placealias`.`pid` AS `pid`,`place`.`parent` AS `parent` from (`place` left join `placealias` on((`place`.`id` = `placealias`.`pid`)));

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

--
-- Struktur des Views `placedomainview`
--
DROP TABLE IF EXISTS `placedomainview`;

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `placedomainview` AS select `placedomain`.`pid` AS `pid`,`placedomain`.`did` AS `did`,`domain`.`name` AS `name` from ((`placedomain` left join `place` on((`place`.`id` = `placedomain`.`pid`))) left join `domain` on((`domain`.`id` = `placedomain`.`did`)));

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

--
-- Struktur des Views `placeinformationview`
--
DROP TABLE IF EXISTS `placeinformationview`;

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `placeinformationview` AS select `placeinformation`.`pid` AS `pid`,`placeinformation`.`iid` AS `iid`,`information`.`name` AS `name`,`placeinformation`.`value` AS `value` from ((`placeinformation` left join `place` on((`place`.`id` = `placeinformation`.`pid`))) left join `information` on((`information`.`id` = `placeinformation`.`iid`)));

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

--
-- Struktur des Views `placeserviceview`
--
DROP TABLE IF EXISTS `placeserviceview`;

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `placeserviceview` AS select `placeservice`.`pid` AS `pid`,`placeservice`.`sid` AS `sid`,`service`.`name` AS `name`,`service`.`sap` AS `sap`,`placeservice`.`request` AS `request` from ((`placeservice` left join `service` on((`service`.`id` = `placeservice`.`sid`))) left join `place` on((`place`.`id` = `placeservice`.`pid`)));

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

--
-- Struktur des Views `pss`
--
DROP TABLE IF EXISTS `pss`;

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `pss` AS select `placeservice`.`pid` AS `pid`,`placeservice`.`sid` AS `sid`,`service`.`name` AS `sName`,`service`.`sap` AS `sap`,`placeservice`.`request` AS `request` from ((`placeservice` left join `service` on((`service`.`id` = `placeservice`.`sid`))) left join `place` on((`place`.`id` = `placeservice`.`pid`)));

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

--
-- Struktur des Views `sps`
--
DROP TABLE IF EXISTS `sps`;

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `sps` AS select `place`.`id` AS `id`,`place`.`plan` AS `plan`,astext(centroid(`place`.`plan`)) AS `refpoint`,`place`.`parent` AS `parent`,`placedomain`.`did` AS `did`,`domain`.`name` AS `dName`,`placealias`.`aid` AS `aid`,`placealias`.`alias` AS `alias` from (((`place` left join `placedomain` on((`place`.`id` = `placedomain`.`pid`))) left join `domain` on((`domain`.`id` = `placedomain`.`did`))) left join `placealias` on((`place`.`id` = `placealias`.`pid`)));

--
-- Constraints der exportierten Tabellen
--

--
-- Constraints der Tabelle `placealias`
--
ALTER TABLE `placealias`
  ADD CONSTRAINT `placealias_ibfk_1` FOREIGN KEY (`pid`) REFERENCES `place` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints der Tabelle `placedomain`
--
ALTER TABLE `placedomain`
  ADD CONSTRAINT `placedomain_ibfk_1` FOREIGN KEY (`pid`) REFERENCES `place` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `placedomain_ibfk_2` FOREIGN KEY (`did`) REFERENCES `domain` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints der Tabelle `placeinformation`
--
ALTER TABLE `placeinformation`
  ADD CONSTRAINT `placeinformation_ibfk_1` FOREIGN KEY (`pid`) REFERENCES `place` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `placeinformation_ibfk_2` FOREIGN KEY (`iid`) REFERENCES `information` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints der Tabelle `placeservice`
--
ALTER TABLE `placeservice`
  ADD CONSTRAINT `placeservice_ibfk_1` FOREIGN KEY (`pid`) REFERENCES `place` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `placeservice_ibfk_2` FOREIGN KEY (`sid`) REFERENCES `service` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
