-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Apr 07, 2026 at 06:47 PM
-- Server version: 10.4.32-MariaDB
-- PHP Version: 8.2.12

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
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 utf8mb4 */;

--
-- Database: `signalplans_ek`
--

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

--
-- Table structure for table `intersections`
--

CREATE TABLE `intersections` (
  `id` int(11) NOT NULL COMMENT 'unikals krustojuma id (izmanto dropdown izvelei un datu piesaistei)',
  `name` varchar(255) NOT NULL COMMENT 'krustojuma nosaukums, kas tiek attelots lapa'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='krustojumu saraksts, katram krustojumam viens ieraksts';

--
-- Dumping data for table `intersections`
--

INSERT INTO `intersections` (`id`, `name`) VALUES
(1, 'Atmodas-Asteru'),
(2, 'Brīvības-Garozas'),
(3, 'Brīvības-Lāčplēša'),
(4, 'Dobeles-4.līnija'),
(5, 'Dobeles-5.līnija'),
(6, 'Dobeles-Atmodas'),
(7, 'Dobeles-Brieža'),
(8, 'Dobeles-Pasta-Blaumaņa'),
(9, 'Dobeles-Satiksmes-Aspazijas'),
(10, 'Dobeles-Uzvaras'),
(11, 'liela akademijas uzvara'),
(12, 'Lielā-Čakstes'),
(13, 'Lielā-Dambja-Barona'),
(14, 'Lielā-IKI'),
(15, 'Lielā-Kalpaka'),
(16, 'Lielā-Katoļu'),
(17, 'Lielā-Māras-Dobeles'),
(18, 'liela matera'),
(19, 'Lielā-Pasta'),
(20, 'Lielā-Pētera-Barona'),
(21, 'Lietuvas-Miera-Platones'),
(22, 'Lietuvas-Savienības'),
(23, 'Mātera-Svētes'),
(24, 'Mātera-Zirgu'),
(26, 'Pasta-Driksas'),
(27, 'Pasta-Edžus'),
(28, 'Pasta-Sporta-Zirgu'),
(29, 'Pasta-Stacijas'),
(30, 'Raiņa-Akadēmijas'),
(31, 'Raiņa-Kalpaka'),
(32, 'Raiņa-Katoļu'),
(33, 'Raiņa-Mātera'),
(34, 'Raiņa-Pasta'),
(35, 'Raiņa-Tērvetes-Sarmas-Filozofu'),
(36, 'Rīgas-Brīvības'),
(37, 'rigas instituta lacplesa'),
(38, 'Rīgas-Izstādes'),
(39, 'Rīgas-Kalnciema-Garozas'),
(40, 'Rīgas-Keramika'),
(41, 'Rīgas-Loka'),
(42, 'Rīgas-Pērnavas-Pumpura'),
(43, 'Rīgas-Strazdu'),
(44, 'Rūpniecības'),
(45, 'Rūpniecības-Dambja-Atmodas'),
(46, 'Rūpniecības-Filozofu'),
(47, 'Rūpniecības-Kalpaka-Dzelzceļnieku'),
(48, 'Rūpniecības-Mātera'),
(49, 'Rūpniecības-Tērvetes'),
(50, 'Satiksmes-Meiju-Zvejnieku'),
(51, 'Uzvaras-Barona'),
(52, 'Zemgales-Jāņa-Palīdzības'),
(53, 'Zemgales-Sporta'),
(54, 'Zemgales-Stacijas'),
(55, 'Pasta-Barona'),
(56, 'Dobeles-3.līnija-Malkas');

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

--
-- Table structure for table `signal_cycles`
--

CREATE TABLE `signal_cycles` (
  `id` int(11) NOT NULL COMMENT 'Ieraksta ID',
  `intersection_id` int(11) NOT NULL COMMENT 'Piederība krustojumam',
  `cycle_length` int(11) NOT NULL COMMENT 'Cikla garums sekundēs',
  `amber` int(11) NOT NULL COMMENT 'Amber laiks sekundēs ',
  `flash` int(11) NOT NULL COMMENT 'Flash laiks sekundēs',
  `yellow` int(11) NOT NULL COMMENT 'Dzeltens laiks pēc zaļā'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Signālplāna cikla parametri katram krustojumam';

--
-- Dumping data for table `signal_cycles`
--

INSERT INTO `signal_cycles` (`id`, `intersection_id`, `cycle_length`, `amber`, `flash`, `yellow`) VALUES
(1, 11, 96, 2, 5, 3),
(2, 37, 81, 2, 5, 3),
(3, 18, 117, 2, 5, 3);

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

--
-- Table structure for table `signal_directions`
--

CREATE TABLE `signal_directions` (
  `id` int(11) NOT NULL COMMENT 'Ieraksta ID',
  `intersection_id` int(11) NOT NULL COMMENT 'Piederība krustojumam',
  `code` varchar(20) NOT NULL COMMENT 'Signāla nosaukums (v1, gp1 u.t.t.)',
  `type` enum('A','V','P') NOT NULL COMMENT 'Signala tips A / V / P',
  `green_time` int(11) NOT NULL COMMENT 'Zaļā ilgums sekundēs',
  `offset` int(11) NOT NULL COMMENT 'Nobīde sekundēs no cikla sākuma, kad sākas zaļais'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Visi signāla objekti krustojumā ar zaļā laiku un sākuma nobīdi';

--
-- Dumping data for table `signal_directions`
--

INSERT INTO `signal_directions` (`id`, `intersection_id`, `code`, `type`, `green_time`, `offset`) VALUES
(1, 11, 'V4', 'V', 56, 32),
(2, 11, 'V6', 'V', 39, 0),
(3, 11, 'V7', 'V', 20, 1),
(4, 11, 'V10', 'V', 57, 32),
(5, 11, 'V12', 'A', 22, 92),
(6, 11, 'GP4', 'P', 25, 0),
(7, 11, 'GP6', 'P', 11, 17),
(8, 11, 'GP7', 'P', 55, 32),
(9, 11, 'GP10', 'P', 25, 0),
(10, 11, 'GP12', 'P', 47, 32),
(11, 37, 'V1', 'V', 18, 0),
(12, 37, 'V4', 'V', 49, 21),
(13, 37, 'V10', 'V', 49, 21),
(14, 37, 'GP1', 'P', 46, 19),
(15, 37, 'GP4', 'P', 15, 0),
(16, 37, 'GP7', 'P', 46, 19),
(17, 37, 'GP10', 'P', 15, 0),
(18, 18, 'V1', 'V', 25, 56),
(19, 18, 'V4', 'V', 79, 0),
(20, 18, 'V7', 'V', 25, 56),
(21, 18, 'V10', 'V', 62, 0),
(22, 18, 'GP1', 'P', 44, 0),
(23, 18, 'GP4', 'P', 22, 56),
(24, 18, 'GP7', 'P', 44, 0),
(25, 18, 'GP10', 'P', 22, 56);

--
-- Indexes for dumped tables
--

--
-- Indexes for table `intersections`
--
ALTER TABLE `intersections`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `signal_cycles`
--
ALTER TABLE `signal_cycles`
  ADD PRIMARY KEY (`id`),
  ADD KEY `intersection_id` (`intersection_id`);

--
-- Indexes for table `signal_directions`
--
ALTER TABLE `signal_directions`
  ADD PRIMARY KEY (`id`),
  ADD KEY `intersection_id` (`intersection_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `signal_cycles`
--
ALTER TABLE `signal_cycles`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Ieraksta ID', AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `signal_directions`
--
ALTER TABLE `signal_directions`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Ieraksta ID', AUTO_INCREMENT=26;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `signal_cycles`
--
ALTER TABLE `signal_cycles`
  ADD CONSTRAINT `signal_cycles_ibfk_1` FOREIGN KEY (`intersection_id`) REFERENCES `intersections` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `signal_directions`
--
ALTER TABLE `signal_directions`
  ADD CONSTRAINT `signal_directions_ibfk_1` FOREIGN KEY (`intersection_id`) REFERENCES `intersections` (`id`) ON DELETE CASCADE;
COMMIT;

/*!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 */;
