This repository was archived by the owner on Sep 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sql
More file actions
177 lines (133 loc) · 3.63 KB
/
init.sql
File metadata and controls
177 lines (133 loc) · 3.63 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
---
--- Drop tables
---
DROP TABLE IF EXISTS Booking;
DROP TABLE IF EXISTS Storage;
DROP TABLE IF EXISTS Family;
DROP TABLE IF EXISTS Pokemon;
DROP TABLE IF EXISTS PokeDex;
DROP TABLE IF EXISTS Client;
---
--- Create tables
---
CREATE TABLE PokeDex (
dex_num int not null,
dex_name text,
type text,
weight float,
height float,
PRIMARY KEY (dex_num)
);
CREATE TABLE Client (
owner_id int not null,
name text,
address text,
phone_num text,
PRIMARY KEY (owner_id)
);
CREATE TABLE Pokemon (
poke_id int not null,
owner_id int references Client(owner_id),
pokedex_num int references PokeDex(dex_num),
name text,
level int not null check (level between 1 and 100),
gender char(1) not null,
dob date,
PRIMARY KEY (poke_id)
);
CREATE TABLE Family (
child int unique references Pokemon(poke_id),
parent_m int references Pokemon(poke_id),
parent_f int references Pokemon(poke_id),
PRIMARY KEY (child, parent_m, parent_f)
);
CREATE TABLE Storage (
room_num text not null,
PRIMARY KEY (room_num)
);
CREATE TABLE Booking (
booking_id int not null,
room_num text references Storage(room_num),
poke_id int references Pokemon(poke_id),
date_in date,
date_out date,
PRIMARY KEY (booking_id)
);
---
--- Insert values
---
INSERT INTO Client
VALUES (100001, 'John Freeman', '1234 Dummy Street', '812-905-0111');
INSERT INTO Client
VALUES (100002, 'George Gore', '8585 Blessings Lane', '502-857-3847');
INSERT INTO Client
VALUES (100003, 'Jane McLane', '9345 Blaze Street', '382-394-2937');
INSERT INTO Client
VALUES (100004, 'Bob Jobs', '4201 9th Ave', '390-392-2929');
INSERT INTO Client
VALUES (100005, 'Victor Smith', '3890 10th Ave', '809-405-4930');
--PokeDex Table Inserts
INSERT INTO PokeDex
VALUES (1, 'Bulbasuar', 'Grass/Poison', 15.2, 28);
INSERT INTO PokeDex
VALUES (4, 'Charmander', 'Fire', 18.7, 24);
INSERT INTO PokeDex
VALUES (7, 'Squirtle', 'Water', 19.8, 20);
INSERT INTO PokeDex
VALUES (25, 'Pikachu', 'Electric', 13.2, 16);
INSERT INTO PokeDex
VALUES (039, 'Jigglypuff', 'Normal-Fairy', 12.1, 20);
INSERT INTO PokeDex
VALUES (078, 'Rapidash', 'Fire', 209.4, 67);
INSERT INTO PokeDex
VALUES (120, 'Staryu', 'Water', 76.1, 31);
INSERT INTO PokeDex
VALUES (133, 'Eevee', 'Normal', 14.3, 12);
INSERT INTO PokeDex
VALUES (132, 'Ditto', 'Normal', 8.8, 12);
--Storage Table Inserts
INSERT INTO Storage
VALUES ('101');
INSERT INTO Storage
VALUES ('102');
INSERT INTO Storage
VALUES ('103');
INSERT INTO Storage
VALUES ('104');
INSERT INTO Storage
VALUES ('A1');
INSERT INTO Storage
VALUES ('A2');
INSERT INTO Storage
VALUES ('A3');
--Pokemon Table Inserts
INSERT INTO Pokemon
VALUES (23489, 100001, 1, 'Bulby', 20, 'M', NULL);
INSERT INTO Pokemon
VALUES (23765, 100001, 4, 'Charmander', 5, 'F', NULL);
INSERT INTO Pokemon
VALUES (48376, 100001, 132, 'Ditto', 9, 'M', NULL);
INSERT INTO Pokemon
VALUES (01928, 100001, 7, 'Squirty', 35, 'F', NULL);
INSERT INTO Pokemon
VALUES (61726, 100001, 7, 'Squirtle', 1, 'M', '4-21-2023');
INSERT INTO Pokemon
VALUES (23498, 100001, 132, 'Diiito', 3, 'F', '4-15-2023');
--Birthday Table Inserts
INSERT INTO Family
VALUES (61726, 48376, 01928);
INSERT INTO Family
VALUES (23498, 48376, 01928);
--Booking Table Inserts
INSERT INTO Booking
VALUES (12387, '101', 23489, '4-20-2023', '4-21-2023');
INSERT INTO Booking
VALUES (12863, '102', 23765, '4-20-2023', NULL);
INSERT INTO Booking
VALUES (94876, '103', 48376, '4-20-2023', NULL);
INSERT INTO Booking
VALUES (90282, '104', 01928, '4-20-2023', NULL);
INSERT INTO Booking
VALUES (74365, 'A1', 61726, '4-22-2023', NULL);
INSERT INTO Booking
VALUES (35292, 'A2', 23498, '4-24-2023', NULL);