Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@teacplusplus
Created September 14, 2021 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teacplusplus/90f913b3d07496966f067e92082b51d6 to your computer and use it in GitHub Desktop.
Save teacplusplus/90f913b3d07496966f067e92082b51d6 to your computer and use it in GitHub Desktop.
CREATE TABLE `countries` (
`country_id` int(11) NOT NULL,
`country` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT NULL, #название страны на официальном языке страны
`country_english` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, #название страны на английском языке страны
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
ALTER TABLE `countries`
MODIFY `country_id` int(11) NOT NULL AUTO_INCREMENT;
COMMIT;
CREATE TABLE `cities` (
`city_id` int(11) NOT NULL,
`city` char(255) COLLATE utf8mb4_unicode_ci NOT NULL, #название города на официальном языке страны
`country_id` int(11) NOT NULL,
`city_english` varchar(255) COLLATE utf8mb4_unicode_ci, DEFAULT NULL #название города на английском языке
`longitude` float(10, 6) NOT NULL, #координаты города
`latitude` float(10, 6) NOT NULL #координаты города
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
ALTER TABLE `cities`
MODIFY `city_id` int(11) NOT NULL AUTO_INCREMENT;
COMMIT;
CREATE TABLE `cities_nearest` (
`city_id` int(10) NOT NULL,
`nearest_city_id` int(10) NOT NULL,
`distance` int(10) NOT NULL # расстояние между городами
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
ALTER TABLE `cities_nearest`
ADD PRIMARY KEY (`city_id`,`nearest_city_id`);
COMMIT;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment