-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_db.sql
More file actions
39 lines (32 loc) · 729 Bytes
/
Copy pathcreate_db.sql
File metadata and controls
39 lines (32 loc) · 729 Bytes
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
CREATE TABLE cities (
id INTEGER PRIMARY KEY,
name VARCHAR(255) NOT NULL,
country_id INTEGER,
FOREIGN KEY(country_id) REFERENCES country(id)
);
CREATE TABLE countries (
id INTEGER PRIMARY KEY,
name VARCHAR(255) NOT NULL,
president_id INTEGER,
FOREIGN KEY(president_id) REFERENCES president(id)
);
CREATE TABLE presidents (
id INTEGER PRIMARY KEY,
name VARCHAR(255) NOT NULL
);
INSERT INTO
presidents (id, name)
VALUES
(1, "Barack Obama"), (2, "Vladimir Putin");
INSERT INTO
cities (id, name, country_id)
VALUES
(1, "San Francisco", 1),
(2, "Tallahassee", 1),
(3, "Moscow", 2),
(4, "Tambov", 2);
INSERT INTO
countries (id, name, president_id)
VALUES
(1, "USA", 1),
(2, "Russia", 2);