Skip to content

Commit c5de545

Browse files
add Assignment 7
1 parent 3f7e7a7 commit c5de545

10 files changed

+2521
-5132
lines changed

db-course/004-DatabaseHotel.ipynb

Lines changed: 69 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,27 @@
4242
},
4343
{
4444
"cell_type": "code",
45-
"execution_count": 3,
45+
"execution_count": 1,
4646
"id": "fc703fb8",
4747
"metadata": {},
48-
"outputs": [],
48+
"outputs": [
49+
{
50+
"name": "stderr",
51+
"output_type": "stream",
52+
"text": [
53+
"[2023-10-31 21:29:48,070][INFO]: Connecting [email protected]:3306\n",
54+
"[2023-10-31 21:29:48,100][INFO]: Connected [email protected]:3306\n"
55+
]
56+
}
57+
],
4958
"source": [
5059
"import datajoint as dj\n",
5160
"schema = dj.Schema('hotel')"
5261
]
5362
},
5463
{
5564
"cell_type": "code",
56-
"execution_count": 4,
65+
"execution_count": 2,
5766
"id": "62d97e04",
5867
"metadata": {},
5968
"outputs": [],
@@ -69,7 +78,7 @@
6978
},
7079
{
7180
"cell_type": "code",
72-
"execution_count": 5,
81+
"execution_count": 3,
7382
"id": "280e7440",
7483
"metadata": {},
7584
"outputs": [],
@@ -86,7 +95,7 @@
8695
},
8796
{
8897
"cell_type": "code",
89-
"execution_count": 6,
98+
"execution_count": 4,
9099
"id": "dc952e39",
91100
"metadata": {},
92101
"outputs": [],
@@ -103,7 +112,7 @@
103112
},
104113
{
105114
"cell_type": "code",
106-
"execution_count": 7,
115+
"execution_count": 5,
107116
"id": "14929f5b",
108117
"metadata": {},
109118
"outputs": [],
@@ -120,7 +129,7 @@
120129
},
121130
{
122131
"cell_type": "code",
123-
"execution_count": 8,
132+
"execution_count": 6,
124133
"id": "61f03f74",
125134
"metadata": {},
126135
"outputs": [],
@@ -134,7 +143,7 @@
134143
},
135144
{
136145
"cell_type": "code",
137-
"execution_count": 9,
146+
"execution_count": 7,
138147
"id": "c163c97c",
139148
"metadata": {},
140149
"outputs": [],
@@ -148,7 +157,7 @@
148157
},
149158
{
150159
"cell_type": "code",
151-
"execution_count": 10,
160+
"execution_count": 8,
152161
"id": "c98936a8",
153162
"metadata": {},
154163
"outputs": [
@@ -159,93 +168,93 @@
159168
"<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 323)\">\n",
160169
"<title>%3</title>\n",
161170
"<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-323 168,-323 168,4 -4,4\"/>\n",
162-
"<!-- CheckIn -->\n",
163-
"<g id=\"node1\" class=\"node\">\n",
164-
"<title>CheckIn</title>\n",
165-
"<g id=\"a_node1\"><a xlink:title=\"→ Reservation\r\">\n",
166-
"<polygon fill=\"#00ff00\" fill-opacity=\"0.188235\" stroke=\"#00ff00\" stroke-opacity=\"0.188235\" points=\"99.5,-106 38.5,-106 38.5,-71 99.5,-71 99.5,-106\"/>\n",
167-
"<text text-anchor=\"middle\" x=\"69\" y=\"-85.4\" font-family=\"arial\" font-size=\"12.00\" fill=\"darkgreen\">CheckIn</text>\n",
168-
"</a>\n",
169-
"</g>\n",
170-
"</g>\n",
171171
"<!-- CheckOut -->\n",
172-
"<g id=\"node3\" class=\"node\">\n",
172+
"<g id=\"node1\" class=\"node\">\n",
173173
"<title>CheckOut</title>\n",
174-
"<g id=\"a_node3\"><a xlink:title=\"→ CheckIn\r\">\n",
175-
"<polygon fill=\"#00ff00\" fill-opacity=\"0.188235\" stroke=\"#00ff00\" stroke-opacity=\"0.188235\" points=\"104,-35 34,-35 34,0 104,0 104,-35\"/>\n",
176-
"<text text-anchor=\"middle\" x=\"69\" y=\"-14.4\" font-family=\"arial\" font-size=\"12.00\" fill=\"darkgreen\">CheckOut</text>\n",
174+
"<g id=\"a_node1\"><a xlink:title=\"→ CheckIn\r\">\n",
175+
"<polygon fill=\"#00ff00\" fill-opacity=\"0.188235\" stroke=\"#00ff00\" stroke-opacity=\"0.188235\" points=\"129,-35 59,-35 59,0 129,0 129,-35\"/>\n",
176+
"<text text-anchor=\"middle\" x=\"94\" y=\"-14.4\" font-family=\"arial\" font-size=\"12.00\" fill=\"darkgreen\">CheckOut</text>\n",
177177
"</a>\n",
178178
"</g>\n",
179179
"</g>\n",
180-
"<!-- CheckIn&#45;&gt;CheckOut -->\n",
181-
"<g id=\"edge1\" class=\"edge\">\n",
182-
"<title>CheckIn-&gt;CheckOut</title>\n",
183-
"<path fill=\"none\" stroke=\"#000000\" stroke-width=\"2\" stroke-opacity=\"0.250980\" d=\"M69,-70.8C69,-59.95 69,-45.87 69,-35.05\"/>\n",
184-
"</g>\n",
185180
"<!-- Room -->\n",
186181
"<g id=\"node2\" class=\"node\">\n",
187182
"<title>Room</title>\n",
188183
"<g id=\"a_node2\"><a xlink:title=\"room                 \r------------------------------\rroom_type            \r\">\n",
189-
"<polygon fill=\"#00ff00\" fill-opacity=\"0.188235\" stroke=\"#00ff00\" stroke-opacity=\"0.188235\" points=\"139.5,-319 90.5,-319 90.5,-284 139.5,-284 139.5,-319\"/>\n",
190-
"<text text-anchor=\"start\" x=\"98.5\" y=\"-299.4\" font-family=\"arial\" text-decoration=\"underline\" font-size=\"12.00\" fill=\"darkgreen\">Room</text>\n",
184+
"<polygon fill=\"#00ff00\" fill-opacity=\"0.188235\" stroke=\"#00ff00\" stroke-opacity=\"0.188235\" points=\"73.5,-319 24.5,-319 24.5,-284 73.5,-284 73.5,-319\"/>\n",
185+
"<text text-anchor=\"start\" x=\"32.5\" y=\"-299.4\" font-family=\"arial\" text-decoration=\"underline\" font-size=\"12.00\" fill=\"darkgreen\">Room</text>\n",
191186
"</a>\n",
192187
"</g>\n",
193188
"</g>\n",
194189
"<!-- RoomAvailable -->\n",
195190
"<g id=\"node5\" class=\"node\">\n",
196191
"<title>RoomAvailable</title>\n",
197192
"<g id=\"a_node5\"><a xlink:title=\"→ Room\rdate                 \r------------------------------\rprice                \r\">\n",
198-
"<polygon fill=\"#00ff00\" fill-opacity=\"0.188235\" stroke=\"#00ff00\" stroke-opacity=\"0.188235\" points=\"164,-248 66,-248 66,-213 164,-213 164,-248\"/>\n",
199-
"<text text-anchor=\"start\" x=\"74\" y=\"-228.4\" font-family=\"arial\" text-decoration=\"underline\" font-size=\"12.00\" fill=\"darkgreen\">RoomAvailable</text>\n",
193+
"<polygon fill=\"#00ff00\" fill-opacity=\"0.188235\" stroke=\"#00ff00\" stroke-opacity=\"0.188235\" points=\"98,-248 0,-248 0,-213 98,-213 98,-248\"/>\n",
194+
"<text text-anchor=\"start\" x=\"8\" y=\"-228.4\" font-family=\"arial\" text-decoration=\"underline\" font-size=\"12.00\" fill=\"darkgreen\">RoomAvailable</text>\n",
200195
"</a>\n",
201196
"</g>\n",
202197
"</g>\n",
203198
"<!-- Room&#45;&gt;RoomAvailable -->\n",
204-
"<g id=\"edge2\" class=\"edge\">\n",
199+
"<g id=\"edge1\" class=\"edge\">\n",
205200
"<title>Room-&gt;RoomAvailable</title>\n",
206-
"<path fill=\"none\" stroke=\"#000000\" stroke-width=\"0.75\" stroke-opacity=\"0.250980\" d=\"M115,-283.8C115,-272.95 115,-258.87 115,-248.05\"/>\n",
201+
"<path fill=\"none\" stroke=\"#000000\" stroke-width=\"0.75\" stroke-opacity=\"0.250980\" d=\"M49,-283.8C49,-272.95 49,-258.87 49,-248.05\"/>\n",
207202
"</g>\n",
208-
"<!-- Guest -->\n",
209-
"<g id=\"node4\" class=\"node\">\n",
210-
"<title>Guest</title>\n",
211-
"<g id=\"a_node4\"><a xlink:title=\"guest_id             \r------------------------------\rguest_name           \rINDEX (guest_name)\r\">\n",
212-
"<polygon fill=\"#00ff00\" fill-opacity=\"0.188235\" stroke=\"#00ff00\" stroke-opacity=\"0.188235\" points=\"48,-248 0,-248 0,-213 48,-213 48,-248\"/>\n",
213-
"<text text-anchor=\"start\" x=\"8\" y=\"-228.4\" font-family=\"arial\" text-decoration=\"underline\" font-size=\"12.00\" fill=\"darkgreen\">Guest</text>\n",
203+
"<!-- CheckIn -->\n",
204+
"<g id=\"node3\" class=\"node\">\n",
205+
"<title>CheckIn</title>\n",
206+
"<g id=\"a_node3\"><a xlink:title=\"→ Reservation\r\">\n",
207+
"<polygon fill=\"#00ff00\" fill-opacity=\"0.188235\" stroke=\"#00ff00\" stroke-opacity=\"0.188235\" points=\"124.5,-106 63.5,-106 63.5,-71 124.5,-71 124.5,-106\"/>\n",
208+
"<text text-anchor=\"middle\" x=\"94\" y=\"-85.4\" font-family=\"arial\" font-size=\"12.00\" fill=\"darkgreen\">CheckIn</text>\n",
214209
"</a>\n",
215210
"</g>\n",
216211
"</g>\n",
212+
"<!-- CheckIn&#45;&gt;CheckOut -->\n",
213+
"<g id=\"edge2\" class=\"edge\">\n",
214+
"<title>CheckIn-&gt;CheckOut</title>\n",
215+
"<path fill=\"none\" stroke=\"#000000\" stroke-width=\"2\" stroke-opacity=\"0.250980\" d=\"M94,-70.8C94,-59.95 94,-45.87 94,-35.05\"/>\n",
216+
"</g>\n",
217217
"<!-- Reservation -->\n",
218-
"<g id=\"node6\" class=\"node\">\n",
218+
"<g id=\"node4\" class=\"node\">\n",
219219
"<title>Reservation</title>\n",
220-
"<g id=\"a_node6\"><a xlink:title=\"→ RoomAvailable\r------------------------------\r→ Guest\rcredit_card          \r\">\n",
221-
"<polygon fill=\"#00ff00\" fill-opacity=\"0.188235\" stroke=\"#00ff00\" stroke-opacity=\"0.188235\" points=\"109.5,-177 28.5,-177 28.5,-142 109.5,-142 109.5,-177\"/>\n",
222-
"<text text-anchor=\"middle\" x=\"69\" y=\"-156.4\" font-family=\"arial\" font-size=\"12.00\" fill=\"darkgreen\">Reservation</text>\n",
220+
"<g id=\"a_node4\"><a xlink:title=\"→ RoomAvailable\r------------------------------\r→ Guest\rcredit_card          \r\">\n",
221+
"<polygon fill=\"#00ff00\" fill-opacity=\"0.188235\" stroke=\"#00ff00\" stroke-opacity=\"0.188235\" points=\"134.5,-177 53.5,-177 53.5,-142 134.5,-142 134.5,-177\"/>\n",
222+
"<text text-anchor=\"middle\" x=\"94\" y=\"-156.4\" font-family=\"arial\" font-size=\"12.00\" fill=\"darkgreen\">Reservation</text>\n",
223223
"</a>\n",
224224
"</g>\n",
225225
"</g>\n",
226-
"<!-- Guest&#45;&gt;Reservation -->\n",
226+
"<!-- Reservation&#45;&gt;CheckIn -->\n",
227227
"<g id=\"edge3\" class=\"edge\">\n",
228-
"<title>Guest-&gt;Reservation</title>\n",
229-
"<path fill=\"none\" stroke=\"#000000\" stroke-width=\"0.75\" stroke-dasharray=\"5,2\" stroke-opacity=\"0.250980\" d=\"M34.89,-212.8C41.97,-201.95 51.15,-187.87 58.21,-177.05\"/>\n",
228+
"<title>Reservation-&gt;CheckIn</title>\n",
229+
"<path fill=\"none\" stroke=\"#000000\" stroke-width=\"2\" stroke-opacity=\"0.250980\" d=\"M94,-141.8C94,-130.95 94,-116.87 94,-106.05\"/>\n",
230230
"</g>\n",
231231
"<!-- RoomAvailable&#45;&gt;Reservation -->\n",
232232
"<g id=\"edge4\" class=\"edge\">\n",
233233
"<title>RoomAvailable-&gt;Reservation</title>\n",
234-
"<path fill=\"none\" stroke=\"#000000\" stroke-width=\"2\" stroke-opacity=\"0.250980\" d=\"M103.86,-212.8C96.63,-201.95 87.24,-187.87 80.03,-177.05\"/>\n",
234+
"<path fill=\"none\" stroke=\"#000000\" stroke-width=\"2\" stroke-opacity=\"0.250980\" d=\"M59.89,-212.8C66.97,-201.95 76.15,-187.87 83.21,-177.05\"/>\n",
235235
"</g>\n",
236-
"<!-- Reservation&#45;&gt;CheckIn -->\n",
236+
"<!-- Guest -->\n",
237+
"<g id=\"node6\" class=\"node\">\n",
238+
"<title>Guest</title>\n",
239+
"<g id=\"a_node6\"><a xlink:title=\"guest_id             \r------------------------------\rguest_name           \rINDEX (guest_name)\r\">\n",
240+
"<polygon fill=\"#00ff00\" fill-opacity=\"0.188235\" stroke=\"#00ff00\" stroke-opacity=\"0.188235\" points=\"164,-248 116,-248 116,-213 164,-213 164,-248\"/>\n",
241+
"<text text-anchor=\"start\" x=\"124\" y=\"-228.4\" font-family=\"arial\" text-decoration=\"underline\" font-size=\"12.00\" fill=\"darkgreen\">Guest</text>\n",
242+
"</a>\n",
243+
"</g>\n",
244+
"</g>\n",
245+
"<!-- Guest&#45;&gt;Reservation -->\n",
237246
"<g id=\"edge5\" class=\"edge\">\n",
238-
"<title>Reservation-&gt;CheckIn</title>\n",
239-
"<path fill=\"none\" stroke=\"#000000\" stroke-width=\"2\" stroke-opacity=\"0.250980\" d=\"M69,-141.8C69,-130.95 69,-116.87 69,-106.05\"/>\n",
247+
"<title>Guest-&gt;Reservation</title>\n",
248+
"<path fill=\"none\" stroke=\"#000000\" stroke-width=\"0.75\" stroke-dasharray=\"5,2\" stroke-opacity=\"0.250980\" d=\"M128.86,-212.8C121.63,-201.95 112.24,-187.87 105.03,-177.05\"/>\n",
240249
"</g>\n",
241250
"</g>\n",
242251
"</svg>"
243252
],
244253
"text/plain": [
245-
"<datajoint.diagram.Diagram at 0x7fc158a80c40>"
254+
"<datajoint.diagram.Diagram at 0x7efe9ef203a0>"
246255
]
247256
},
248-
"execution_count": 10,
257+
"execution_count": 8,
249258
"metadata": {},
250259
"output_type": "execute_result"
251260
}
@@ -264,7 +273,7 @@
264273
},
265274
{
266275
"cell_type": "code",
267-
"execution_count": 11,
276+
"execution_count": 9,
268277
"id": "64060872",
269278
"metadata": {},
270279
"outputs": [],
@@ -278,7 +287,7 @@
278287
},
279288
{
280289
"cell_type": "code",
281-
"execution_count": 12,
290+
"execution_count": 10,
282291
"id": "281c8ca7",
283292
"metadata": {},
284293
"outputs": [],
@@ -289,15 +298,15 @@
289298
},
290299
{
291300
"cell_type": "code",
292-
"execution_count": 13,
301+
"execution_count": 11,
293302
"id": "86bc4436",
294303
"metadata": {},
295304
"outputs": [
296305
{
297306
"name": "stderr",
298307
"output_type": "stream",
299308
"text": [
300-
"100%|██████████| 45/45 [00:02<00:00, 20.91it/s]\n"
309+
"100%|██████████| 45/45 [00:01<00:00, 23.68it/s]\n"
301310
]
302311
}
303312
],
@@ -325,7 +334,7 @@
325334
},
326335
{
327336
"cell_type": "code",
328-
"execution_count": 16,
337+
"execution_count": 12,
329338
"id": "48470620",
330339
"metadata": {},
331340
"outputs": [],
@@ -340,7 +349,7 @@
340349
},
341350
{
342351
"cell_type": "code",
343-
"execution_count": 17,
352+
"execution_count": 13,
344353
"id": "5603309c",
345354
"metadata": {},
346355
"outputs": [],
@@ -368,7 +377,7 @@
368377
},
369378
{
370379
"cell_type": "code",
371-
"execution_count": 18,
380+
"execution_count": 14,
372381
"id": "fd3b9e30",
373382
"metadata": {},
374383
"outputs": [],
@@ -384,7 +393,7 @@
384393
},
385394
{
386395
"cell_type": "code",
387-
"execution_count": 19,
396+
"execution_count": 15,
388397
"id": "09e340e2",
389398
"metadata": {},
390399
"outputs": [],

db-course/004-DatabaseNations.ipynb

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,18 @@
99
},
1010
{
1111
"cell_type": "code",
12-
"execution_count": 1,
12+
"execution_count": 2,
1313
"metadata": {},
14-
"outputs": [],
14+
"outputs": [
15+
{
16+
"name": "stdout",
17+
"output_type": "stream",
18+
"text": [
19+
"The sql extension is already loaded. To reload it, use:\n",
20+
" %reload_ext sql\n"
21+
]
22+
}
23+
],
1524
"source": [
1625
"import pymysql\n",
1726
"pymysql.install_as_MySQLdb()\n",
@@ -23,7 +32,7 @@
2332
},
2433
{
2534
"cell_type": "code",
26-
"execution_count": 2,
35+
"execution_count": 3,
2736
"metadata": {},
2837
"outputs": [
2938
{
@@ -140,7 +149,7 @@
140149
"[]"
141150
]
142151
},
143-
"execution_count": 2,
152+
"execution_count": 3,
144153
"metadata": {},
145154
"output_type": "execute_result"
146155
}

db-course/004-DatabaseSales.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616
},
1717
{
1818
"cell_type": "code",
19-
"execution_count": 4,
19+
"execution_count": 2,
2020
"metadata": {},
2121
"outputs": [
2222
{
2323
"name": "stdout",
2424
"output_type": "stream",
2525
"text": [
2626
" * mysql://root:***@127.0.0.1\n",
27-
"3 rows affected.\n",
27+
"0 rows affected.\n",
2828
"1 rows affected.\n",
2929
"0 rows affected.\n",
3030
"0 rows affected.\n",
@@ -53,7 +53,7 @@
5353
"[]"
5454
]
5555
},
56-
"execution_count": 4,
56+
"execution_count": 2,
5757
"metadata": {},
5858
"output_type": "execute_result"
5959
}

0 commit comments

Comments
 (0)