-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcities6.sql
More file actions
44 lines (40 loc) · 1.45 KB
/
cities6.sql
File metadata and controls
44 lines (40 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
1.
SELECT cities.name, regions.name
FROM cities, regions
WHERE population > 350000
AND cities.region = regions.uuid
2.
SELECT cities.name, regions.name
FROM cities, regions
WHERE cities.region = regions.uuid
AND regions.name = "Nord"
3.
SET NAMES utf8;
SET time_zone = '+00:00';
SET foreign_key_checks = 0;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
DROP TABLE IF EXISTS `lines`;
CREATE TABLE `lines` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`color` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
DROP TABLE IF EXISTS `stations`;
CREATE TABLE `stations` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`line_id` int(10) UNSIGNED NOT NULL,
`previous_station` varchar(255) COLLATE utf8_unicode_ci,
`next_station` varchar(255) COLLATE utf8_unicode_ci,
PRIMARY KEY (`id`),
FOREIGN KEY (`line_jd`) REFERENCES `lines`(`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
DROP TABLE IF EXISTS `transitions`;
CREATE TABLE `transitions` (
`start_station` int(10) unsigned NOT NULL,
`end_station` int(10) unsigned NOT NULL,
PRIMARY KEY (`start_station`, `end_station`),
FOREIGN KEY (`start_station`) REFERENCES `stations`(`id`),
FOREIGN KEY (`end_station`) REFERENCES `stations`(`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;