-- ================================================================
-- tk_objekti
-- ================================================================

USE tk_objekti;

DROP TABLE IF EXISTS `index`;
CREATE TABLE `index` (
  `id`     INT UNSIGNED NOT NULL COMMENT 'Adreses indeksa ID',
  `number` DECIMAL(4,0) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Adreses indekss',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `number` (`number`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
  ROW_FORMAT=DYNAMIC COMMENT='Pasta indeksu tabula';

INSERT INTO `index` (id, number) VALUES
(0, 0),
(1, 1001),
(2, 1002),
(3, 1003),
(4, 1004),
(5, 1005),
(6, 1006),
(7, 1007),
(8, 1009),
(9, 1010),
(10, 1011),
(11, 1012),
(12, 1013),
(13, 1014),
(14, 1015),
(15, 1016),
(16, 1019),
(17, 1021),
(18, 1023),
(19, 1024),
(20, 1026),
(21, 1029),
(22, 1030),
(23, 1034),
(24, 1035),
(25, 1039),
(26, 1044),
(27, 1045),
(28, 1046),
(29, 1048),
(30, 1050),
(31, 1053),
(32, 1055),
(33, 1057),
(34, 1058),
(35, 1063),
(36, 1064),
(37, 1067),
(38, 1069),
(39, 1073),
(40, 1076),
(41, 1079),
(42, 1081),
(43, 1082),
(44, 1083),
(45, 1084),
(46, 2008),
(47, 2010),
(48, 2011),
(49, 2012),
(50, 2015),
(51, 2016),
(52, 2101),
(53, 2103),
(54, 2105),
(55, 2107),
(56, 2108),
(57, 2111),
(58, 2112),
(59, 2113),
(60, 2114),
(61, 2117),
(62, 2118),
(63, 2119),
(64, 2121),
(65, 2123),
(66, 2124),
(67, 2125),
(68, 2127),
(69, 2128),
(70, 2130),
(71, 2133),
(72, 2135),
(73, 2136),
(74, 2137),
(75, 2140),
(76, 2141),
(77, 2142),
(78, 2144),
(79, 2145),
(80, 2150),
(81, 2151),
(82, 2152),
(83, 2154),
(84, 2160),
(85, 2161),
(86, 2162),
(87, 2163),
(88, 2164),
(89, 2166),
(90, 2167),
(91, 2169),
(92, 2170),
(93, 3001),
(94, 3002),
(95, 3003),
(96, 3004),
(97, 3007),
(98, 3008),
(99, 3011),
(100, 3014),
(101, 3016),
(102, 3017),
(103, 3018),
(104, 3020),
(105, 3021),
(106, 3022),
(107, 3023),
(108, 3026),
(109, 3028),
(110, 3031),
(111, 3034),
(112, 3036),
(113, 3037),
(114, 3040),
(115, 3042),
(116, 3043),
(117, 3045),
(118, 3101),
(119, 3104),
(120, 3110),
(121, 3113),
(122, 3118),
(123, 3119),
(124, 3120),
(125, 3122),
(126, 3123),
(127, 3124),
(128, 3128),
(129, 3129),
(130, 3131),
(131, 3132),
(132, 3133),
(133, 3134),
(134, 3135),
(135, 3137),
(136, 3139),
(137, 3140),
(138, 3142),
(139, 3145),
(140, 3146),
(141, 3147),
(142, 3148),
(143, 3201),
(144, 3251),
(145, 3253),
(146, 3257),
(147, 3258),
(148, 3260),
(149, 3261),
(150, 3262),
(151, 3264),
(152, 3270),
(153, 3275),
(154, 3280),
(155, 3281),
(156, 3283),
(157, 3284),
(158, 3285),
(159, 3287),
(160, 3291),
(161, 3292),
(162, 3294),
(163, 3297),
(164, 3298),
(165, 3301),
(166, 3306),
(167, 3307),
(168, 3309),
(169, 3310),
(170, 3312),
(171, 3313),
(172, 3314),
(173, 3317),
(174, 3319),
(175, 3320),
(176, 3321),
(177, 3322),
(178, 3323),
(179, 3324),
(180, 3325),
(181, 3326),
(182, 3328),
(183, 3329),
(184, 3330),
(185, 3332),
(186, 3333),
(187, 3401),
(188, 3402),
(189, 3405),
(190, 3407),
(191, 3411),
(192, 3414),
(193, 3416),
(194, 3430),
(195, 3431),
(196, 3433),
(197, 3434),
(198, 3435),
(199, 3436),
(200, 3438),
(201, 3440),
(202, 3441),
(203, 3442),
(204, 3443),
(205, 3444),
(206, 3445),
(207, 3446),
(208, 3447),
(209, 3452),
(210, 3453),
(211, 3455),
(212, 3456),
(213, 3457),
(214, 3461),
(215, 3463),
(216, 3466),
(217, 3473),
(218, 3474),
(219, 3475),
(220, 3476),
(221, 3477),
(222, 3480),
(223, 3482),
(224, 3484),
(225, 3485),
(226, 3486),
(227, 3487),
(228, 3601),
(229, 3602),
(230, 3604),
(231, 3612),
(232, 3613),
(233, 3614),
(234, 3615),
(235, 3617),
(236, 3619),
(237, 3620),
(238, 3621),
(239, 3623),
(240, 3624),
(241, 3626),
(242, 3627),
(243, 3701),
(244, 3708),
(245, 3709),
(246, 3710),
(247, 3711),
(248, 3713),
(249, 3714),
(250, 3716),
(251, 3717),
(252, 3718),
(253, 3719),
(254, 3721),
(255, 3722),
(256, 3723),
(257, 3724),
(258, 3725),
(259, 3729),
(260, 3730),
(261, 3731),
(262, 3732),
(263, 3801),
(264, 3851),
(265, 3852),
(266, 3853),
(267, 3861),
(268, 3862),
(269, 3871),
(270, 3873),
(271, 3875),
(272, 3876),
(273, 3880),
(274, 3882),
(275, 3883),
(276, 3890),
(277, 3891),
(278, 3892),
(279, 3893),
(280, 3894),
(281, 3895),
(282, 3896),
(283, 3897),
(284, 3898),
(285, 3899),
(286, 3901),
(287, 3905),
(288, 3906),
(289, 3907),
(290, 3908),
(291, 3910),
(292, 3913),
(293, 3914),
(294, 3915),
(295, 3917),
(296, 3918),
(297, 3921),
(298, 3924),
(299, 3925),
(300, 3926),
(301, 3927),
(302, 3929),
(303, 3930),
(304, 3931),
(305, 3932),
(306, 3933),
(307, 3936),
(308, 4001),
(309, 4004),
(310, 4010),
(311, 4011),
(312, 4012),
(313, 4013),
(314, 4020),
(315, 4022),
(316, 4023),
(317, 4025),
(318, 4033),
(319, 4035),
(320, 4043),
(321, 4050),
(322, 4052),
(323, 4054),
(324, 4061),
(325, 4063),
(326, 4064),
(327, 4068),
(328, 4101),
(329, 4108),
(330, 4110),
(331, 4112),
(332, 4113),
(333, 4116),
(334, 4118),
(335, 4119),
(336, 4122),
(337, 4123),
(338, 4125),
(339, 4126),
(340, 4128),
(341, 4129),
(342, 4131),
(343, 4132),
(344, 4133),
(345, 4136),
(346, 4139),
(347, 4141),
(348, 4143),
(349, 4144),
(350, 4146),
(351, 4151),
(352, 4152),
(353, 4154),
(354, 4201),
(355, 4202),
(356, 4206),
(357, 4208),
(358, 4210),
(359, 4211),
(360, 4213),
(361, 4215),
(362, 4216),
(363, 4219),
(364, 4220),
(365, 4222),
(366, 4223),
(367, 4224),
(368, 4227),
(369, 4228),
(370, 4232),
(371, 4234),
(372, 4240),
(373, 4241),
(374, 4242),
(375, 4244),
(376, 4245),
(377, 4247),
(378, 4248),
(379, 4301),
(380, 4332),
(381, 4333),
(382, 4335),
(383, 4336),
(384, 4337),
(385, 4339),
(386, 4340),
(387, 4341),
(388, 4342),
(389, 4344),
(390, 4345),
(391, 4348),
(392, 4350),
(393, 4351),
(394, 4352),
(395, 4354),
(396, 4355),
(397, 4358),
(398, 4359),
(399, 4401),
(400, 4405),
(401, 4406),
(402, 4409),
(403, 4410),
(404, 4412),
(405, 4415),
(406, 4416),
(407, 4417),
(408, 4420),
(409, 4421),
(410, 4424),
(411, 4425),
(412, 4426),
(413, 4428),
(414, 4429),
(415, 4501),
(416, 4561),
(417, 4562),
(418, 4566),
(419, 4567),
(420, 4570),
(421, 4571),
(422, 4572),
(423, 4573),
(424, 4574),
(425, 4576),
(426, 4577),
(427, 4580),
(428, 4582),
(429, 4583),
(430, 4584),
(431, 4585),
(432, 4586),
(433, 4587),
(434, 4590),
(435, 4591),
(436, 4592),
(437, 4594),
(438, 4595),
(439, 4601),
(440, 4604),
(441, 4611),
(442, 4612),
(443, 4614),
(444, 4615),
(445, 4616),
(446, 4617),
(447, 4618),
(448, 4619),
(449, 4621),
(450, 4622),
(451, 4623),
(452, 4625),
(453, 4626),
(454, 4627),
(455, 4628),
(456, 4630),
(457, 4631),
(458, 4633),
(459, 4634),
(460, 4635),
(461, 4636),
(462, 4638),
(463, 4640),
(464, 4641),
(465, 4642),
(466, 4643),
(467, 4645),
(468, 4647),
(469, 4648),
(470, 4649),
(471, 4650),
(472, 4652),
(473, 4701),
(474, 4706),
(475, 4707),
(476, 4708),
(477, 4711),
(478, 4712),
(479, 4713),
(480, 4715),
(481, 4716),
(482, 4718),
(483, 4723),
(484, 4724),
(485, 4726),
(486, 4727),
(487, 4728),
(488, 4729),
(489, 4730),
(490, 4731),
(491, 4733),
(492, 4735),
(493, 4801),
(494, 4824),
(495, 4825),
(496, 4826),
(497, 4830),
(498, 4833),
(499, 4834),
(500, 4835),
(501, 4836),
(502, 4837),
(503, 4838),
(504, 4840),
(505, 4841),
(506, 4844),
(507, 4846),
(508, 4847),
(509, 4852),
(510, 4853),
(511, 4855),
(512, 4860),
(513, 4862),
(514, 4863),
(515, 4865),
(516, 4870),
(517, 4871),
(518, 4873),
(519, 4880),
(520, 4884),
(521, 5001),
(522, 5011),
(523, 5012),
(524, 5015),
(525, 5016),
(526, 5020),
(527, 5022),
(528, 5033),
(529, 5041),
(530, 5044),
(531, 5045),
(532, 5047),
(533, 5052),
(534, 5060),
(535, 5062),
(536, 5064),
(537, 5065),
(538, 5070),
(539, 5071),
(540, 5101),
(541, 5106),
(542, 5108),
(543, 5109),
(544, 5110),
(545, 5111),
(546, 5112),
(547, 5113),
(548, 5115),
(549, 5118),
(550, 5120),
(551, 5123),
(552, 5124),
(553, 5125),
(554, 5128),
(555, 5129),
(556, 5130),
(557, 5133),
(558, 5134),
(559, 5135),
(560, 5201),
(561, 5202),
(562, 5204),
(563, 5208),
(564, 5209),
(565, 5210),
(566, 5211),
(567, 5212),
(568, 5214),
(569, 5215),
(570, 5216),
(571, 5217),
(572, 5218),
(573, 5220),
(574, 5221),
(575, 5222),
(576, 5223),
(577, 5224),
(578, 5226),
(579, 5228),
(580, 5229),
(581, 5230),
(582, 5232),
(583, 5236),
(584, 5237),
(585, 5238),
(586, 5239),
(587, 5301),
(588, 5304),
(589, 5305),
(590, 5311),
(591, 5312),
(592, 5315),
(593, 5316),
(594, 5318),
(595, 5320),
(596, 5323),
(597, 5325),
(598, 5326),
(599, 5327),
(600, 5328),
(601, 5329),
(602, 5330),
(603, 5331),
(604, 5333),
(605, 5334),
(606, 5335),
(607, 5337),
(608, 5401),
(609, 5404),
(610, 5410),
(611, 5412),
(612, 5413),
(613, 5414),
(614, 5415),
(615, 5417),
(616, 5418),
(617, 5422),
(618, 5438),
(619, 5439),
(620, 5440),
(621, 5441),
(622, 5442),
(623, 5443),
(624, 5444),
(625, 5447),
(626, 5449),
(627, 5450),
(628, 5451),
(629, 5456),
(630, 5458),
(631, 5459),
(632, 5460),
(633, 5461),
(634, 5462),
(635, 5463),
(636, 5465),
(637, 5469),
(638, 5470),
(639, 5471),
(640, 5473),
(641, 5474),
(642, 5477),
(643, 5481),
(644, 5601),
(645, 5651),
(646, 5652),
(647, 5653),
(648, 5655),
(649, 5656),
(650, 5660),
(651, 5662),
(652, 5664),
(653, 5666),
(654, 5668),
(655, 5671),
(656, 5674),
(657, 5676),
(658, 5677),
(659, 5680),
(660, 5681),
(661, 5685),
(662, 5687),
(663, 5692),
(664, 5695),
(665, 5696),
(666, 5697),
(667, 5698),
(668, 5701),
(669, 5704),
(670, 5705),
(671, 5706),
(672, 5707),
(673, 5709),
(674, 5711),
(675, 5716),
(676, 5717),
(677, 5719),
(678, 5722),
(679, 5725),
(680, 5726),
(681, 5729),
(682, 5730),
(683, 5732),
(684, 5733),
(685, 5735),
(686, 5736),
(687, 5737),
(688, 5739),
(689, 5740),
(690, 5742),
(691, 5745),
(692, 5748),
(693, 5750),
(694, 5751),
(695, 5752);

DROP TABLE IF EXISTS level;
CREATE TABLE level (
  `id`    INT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Adreses limena ID',
  `name`  VARCHAR(15)  CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Adreses limenis',
  `fname` VARCHAR(50)  CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT 'Pilnais nosaukums',
  `sname` VARCHAR(5)   CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT 'Isais nosaukums',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `name` (`name`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
  ROW_FORMAT=DYNAMIC COMMENT='Adreses limenis';

INSERT INTO level (id, name, fname, sname) VALUES
(1, 'Valsts', 'Valsts', ' '),
(2, 'Novads', 'Novads', 'nov.'),
(3, 'Pilsēta', 'Pilsēta', ''),
(4, 'Pagasts', 'Pagasts', 'pag.'),
(5, 'Ciems', 'Ciems/ mazciems', ''),
(6, 'Iela', 'Iela', ''),
(7, 'Ēka', 'Ēka/ apbūvei paredzēts zemesgabals/ viensēta', ''),
(8, 'Valsts pilsēta', 'Valsts pilsēta', 'v.p.');
