-- --------------------------------------------------------
-- Хост:                         127.0.0.1
-- Версия сервера:               10.4.32-MariaDB - mariadb.org binary distribution
-- Операционная система:         Win64
-- HeidiSQL Версия:              12.15.0.7171
-- --------------------------------------------------------

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!50503 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;


-- Дамп структуры базы данных jelgava_signalplani3
CREATE DATABASE IF NOT EXISTS `jelgava_signalplani3` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci */;
USE `jelgava_signalplani3`;

-- Дамп структуры для таблица jelgava_signalplani3.krustojumi
CREATE TABLE IF NOT EXISTS `krustojumi` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Unikals ID katram krustojumam',
  `name` varchar(255) NOT NULL COMMENT 'Krustojuma nosaukums, piemers: Dobeles-Atmodas',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=57 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Visi krustojumi Jelgava';

-- Дамп данных таблицы jelgava_signalplani3.krustojumi: ~55 rows (приблизительно)
INSERT INTO `krustojumi` (`id`, `name`) VALUES
	(1, 'Atmodas-Asteru'),
	(2, 'Brivibas-Garozas'),
	(3, 'Brivibas-Lacplesa'),
	(4, 'Dobeles-4.linija'),
	(5, 'Dobeles-5.linija'),
	(6, 'Dobeles-Atmodas'),
	(7, 'Dobeles-Brieza'),
	(8, 'Dobeles-Pasta-Blaumana'),
	(9, 'Dobeles-Satiksmes-Aspazijas'),
	(10, 'Dobeles-Uzvaras'),
	(11, 'Liela-Akademijas-Uzvaras'),
	(12, 'Liela-Cakstes'),
	(13, 'Liela-Dambja-Barona'),
	(14, 'Liela-IKI'),
	(15, 'Liela-Kalpaka'),
	(16, 'Liela-Katolu'),
	(17, 'Liela-Maras-Dobeles'),
	(18, 'Liela-Matera'),
	(19, 'Liela-Pasta'),
	(20, 'Liela-Petera-Barona'),
	(21, 'Lietuvas-Miera-Platones'),
	(22, 'Lietuvas-Savienibas'),
	(23, 'Matera-Svetes'),
	(24, 'Matera-Zirgu'),
	(26, 'Pasta-Driksas'),
	(27, 'Pasta-Edzus'),
	(28, 'Pasta-Sporta-Zirgu'),
	(29, 'Pasta-Stacijas'),
	(30, 'Rainja-Akademijas'),
	(31, 'Rainja-Kalpaka'),
	(32, 'Rainja-Katolu'),
	(33, 'Rainja-Matera'),
	(34, 'Rainja-Pasta'),
	(35, 'Rainja-Tervetes-Sarmas-Filozofu'),
	(36, 'Rigas-Brivibas'),
	(37, 'Rigas-Instituta-Lacplesa'),
	(38, 'Rigas-Izstades'),
	(39, 'Rigas-Kalnciema-Garozas'),
	(40, 'Rigas-Keramika'),
	(41, 'Rigas-Loka'),
	(42, 'Rigas-Pernavas-Pumpura'),
	(43, 'Rigas-Strazdu'),
	(44, 'Rupniecibas'),
	(45, 'Rupniecibas-Dambja-Atmodas'),
	(46, 'Rupniecibas-Filozofu'),
	(47, 'Rupniecibas-Kalpaka-Dzelzcelnieku'),
	(48, 'Rupniecibas-Matera'),
	(49, 'Rupniecibas-Tervetes'),
	(50, 'Satiksmes-Meiju-Zvejnieku'),
	(51, 'Uzvaras-Barona'),
	(52, 'Zemgales-Jana-Palidzibas'),
	(53, 'Zemgales-Sporta'),
	(54, 'Zemgales-Stacijas'),
	(55, 'Pasta-Barona'),
	(56, 'Dobeles-3.linija-Malkas');

-- Дамп структуры для таблица jelgava_signalplani3.signal_plani
CREATE TABLE IF NOT EXISTS `signal_plani` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Unikals ID signal planam',
  `krustojums_id` int(11) NOT NULL COMMENT 'Saite uz krustojumu (krustojumi.id)',
  `cikls` int(11) NOT NULL COMMENT 'Pilns signal cikla laiks sekundes',
  `dzeltansarkans` int(11) DEFAULT 3 COMMENT 'Dzeltansarkana faza sekundes (pirms zala)',
  `sarkans` int(11) DEFAULT 1 COMMENT 'Papildus sarkana laiks sekundes starp fazem',
  `dzeltens` int(11) DEFAULT 3 COMMENT 'Dzeltena faza sekundes (pirms sarkana)',
  PRIMARY KEY (`id`),
  KEY `fk_krustojums` (`krustojums_id`),
  CONSTRAINT `fk_krustojums` FOREIGN KEY (`krustojums_id`) REFERENCES `krustojumi` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Signal plani ar cikla un fazu laikiem katram krustojumam';

-- Дамп данных таблицы jelgava_signalplani3.signal_plani: ~3 rows (приблизительно)
INSERT INTO `signal_plani` (`id`, `krustojums_id`, `cikls`, `dzeltansarkans`, `sarkans`, `dzeltens`) VALUES
	(1, 5, 99, 3, 1, 3),
	(2, 23, 90, 3, 1, 3),
	(3, 50, 120, 3, 1, 3);

-- Дамп структуры для таблица jelgava_signalplani3.virzieni
CREATE TABLE IF NOT EXISTS `virzieni` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Unikals ID vienai rindai',
  `signal_plans_id` int(11) NOT NULL COMMENT 'Saite uz signal planu (signal_plani.id)',
  `nosaukums` varchar(10) NOT NULL COMMENT 'Virziens nosaukums, piemers: V1, GP4',
  `tips` enum('V','A','P') NOT NULL COMMENT 'Tips: V=virziens , A=amber  P= (gajejs)',
  `laiks` decimal(4,1) NOT NULL COMMENT 'Zala signala ilgums sekundes',
  `offset` int(11) NOT NULL DEFAULT 0 COMMENT 'Zala signala sakums no cikla sakuma (sekundes)',
  PRIMARY KEY (`id`),
  KEY `fk_plans` (`signal_plans_id`),
  CONSTRAINT `fk_plans` FOREIGN KEY (`signal_plans_id`) REFERENCES `signal_plani` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Visi virzieni katram signal planam ar laika parametriem';

-- Дамп данных таблицы jelgava_signalplani3.virzieni: ~22 rows (приблизительно)
INSERT INTO `virzieni` (`id`, `signal_plans_id`, `nosaukums`, `tips`, `laiks`, `offset`) VALUES
	(1, 1, 'V4', 'V', 47.0, 0),
	(2, 1, 'V10', 'V', 63.0, 0),
	(3, 1, 'V12', 'A', 10.0, 53),
	(4, 1, 'GP1', 'P', 42.0, 0),
	(5, 1, 'V1', 'V', 23.0, 70),
	(6, 1, 'GP4', 'P', 16.0, 70),
	(7, 1, 'GP10', 'P', 16.0, 70),
	(8, 2, 'V1', 'V', 30.0, 0),
	(9, 2, 'V4', 'V', 24.0, 30),
	(10, 2, 'V7', 'V', 24.0, 30),
	(11, 2, 'V10', 'V', 30.0, 0),
	(12, 2, 'V12', 'A', 10.0, 54),
	(13, 2, 'GP1', 'P', 22.0, 0),
	(14, 2, 'GP4', 'P', 22.0, 0),
	(15, 2, 'GP10', 'P', 22.0, 0),
	(16, 3, 'V1', 'V', 39.0, 0),
	(17, 3, 'V4', 'V', 32.0, 60),
	(18, 3, 'V7', 'V', 39.0, 0),
	(19, 3, 'V10', 'V', 32.0, 60),
	(20, 3, 'GP1', 'P', 16.0, 39),
	(21, 3, 'GP4', 'P', 16.0, 39),
	(22, 3, 'GP10', 'P', 16.0, 39);

/*!40103 SET TIME_ZONE=IFNULL(@OLD_TIME_ZONE, 'system') */;
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40111 SET SQL_NOTES=IFNULL(@OLD_SQL_NOTES, 1) */;
