-
Notifications
You must be signed in to change notification settings - Fork 0
/
cats.sql
43 lines (36 loc) · 838 Bytes
/
cats.sql
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
CREATE TABLE cats (
id INTEGER PRIMARY KEY,
name VARCHAR(255) NOT NULL,
owner_id INTEGER,
FOREIGN KEY(owner_id) REFERENCES human(id)
);
CREATE TABLE humans (
id INTEGER PRIMARY KEY,
fname VARCHAR(255) NOT NULL,
lname VARCHAR(255) NOT NULL,
house_id INTEGER,
FOREIGN KEY(house_id) REFERENCES human(id)
);
CREATE TABLE houses (
id INTEGER PRIMARY KEY,
address VARCHAR(255) NOT NULL
);
INSERT INTO
houses (id, address)
VALUES
(1, "26th and Guerrero"), (2, "Dolores and Market");
INSERT INTO
humans (id, fname, lname, house_id)
VALUES
(1, "Devon", "Watts", 1),
(2, "Matt", "Rubens", 1),
(3, "Ned", "Ruggeri", 2),
(4, "Catless", "Human", NULL);
INSERT INTO
cats (id, name, owner_id)
VALUES
(1, "Breakfast", 1),
(2, "Earl", 2),
(3, "Haskell", 3),
(4, "Markov", 3),
(5, "Stray Cat", NULL);