Skip to content

Commit fd27042

Browse files
add the management hierearchy example
1 parent 65cbe9e commit fd27042

File tree

2 files changed

+1375
-21
lines changed

2 files changed

+1375
-21
lines changed

book/35-example-designs/050-languages-database.ipynb

Lines changed: 85 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"name": "stderr",
7979
"output_type": "stream",
8080
"text": [
81-
"[2025-09-24 22:16:11,186][INFO]: DataJoint 0.14.6 connected to dev@db:3306\n"
81+
"[2025-09-24 23:30:30,659][INFO]: DataJoint 0.14.6 connected to dev@db:3306\n"
8282
]
8383
}
8484
],
@@ -190,6 +190,70 @@
190190
" \"\"\""
191191
]
192192
},
193+
{
194+
"cell_type": "code",
195+
"execution_count": 3,
196+
"metadata": {},
197+
"outputs": [
198+
{
199+
"data": {
200+
"image/svg+xml": [
201+
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"148pt\" height=\"114pt\" viewBox=\"0.00 0.00 147.50 114.00\">\n",
202+
"<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 110)\">\n",
203+
"<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-110 143.5,-110 143.5,4 -4,4\"/>\n",
204+
"<!-- Language -->\n",
205+
"<g id=\"node1\" class=\"node\">\n",
206+
"<title>Language</title>\n",
207+
"<g id=\"a_node1\"><a xlink:title=\"lang_code            &#13;------------------------------&#13;language             &#13;native_name          &#13;\">\n",
208+
"<polygon fill=\"#000000\" fill-opacity=\"0.125490\" stroke=\"transparent\" points=\"64,-106 0,-106 0,-71 64,-71 64,-106\"/>\n",
209+
"<text text-anchor=\"start\" x=\"8\" y=\"-87\" font-family=\"arial\" text-decoration=\"underline\" font-size=\"10.00\">Language</text>\n",
210+
"</a>\n",
211+
"</g>\n",
212+
"</g>\n",
213+
"<!-- Fluency -->\n",
214+
"<g id=\"node2\" class=\"node\">\n",
215+
"<title>Fluency</title>\n",
216+
"<g id=\"a_node2\"><a xlink:title=\"→ Person&#13;→ Language&#13;------------------------------&#13;fluency_level        &#13;\">\n",
217+
"<polygon fill=\"#00ff00\" fill-opacity=\"0.188235\" stroke=\"#00ff00\" stroke-opacity=\"0.188235\" points=\"102,-35 40,-35 40,0 102,0 102,-35\"/>\n",
218+
"<text text-anchor=\"middle\" x=\"71\" y=\"-14.4\" font-family=\"arial\" font-size=\"12.00\" fill=\"darkgreen\">Fluency</text>\n",
219+
"</a>\n",
220+
"</g>\n",
221+
"</g>\n",
222+
"<!-- Language&#45;&gt;Fluency -->\n",
223+
"<g id=\"edge1\" class=\"edge\">\n",
224+
"<title>Language-&gt;Fluency</title>\n",
225+
"<path fill=\"none\" stroke=\"#000000\" stroke-width=\"0.75\" stroke-opacity=\"0.250980\" d=\"M41.44,-70.8C47.57,-59.95 55.53,-45.87 61.65,-35.05\"/>\n",
226+
"</g>\n",
227+
"<!-- Person -->\n",
228+
"<g id=\"node3\" class=\"node\">\n",
229+
"<title>Person</title>\n",
230+
"<g id=\"a_node3\"><a xlink:title=\"person_id            &#13;------------------------------&#13;name                 &#13;date_of_birth        &#13;\">\n",
231+
"<polygon fill=\"#00ff00\" fill-opacity=\"0.188235\" stroke=\"#00ff00\" stroke-opacity=\"0.188235\" points=\"139.5,-106 82.5,-106 82.5,-71 139.5,-71 139.5,-106\"/>\n",
232+
"<text text-anchor=\"start\" x=\"90.5\" y=\"-86.4\" font-family=\"arial\" text-decoration=\"underline\" font-size=\"12.00\" fill=\"darkgreen\">Person</text>\n",
233+
"</a>\n",
234+
"</g>\n",
235+
"</g>\n",
236+
"<!-- Person&#45;&gt;Fluency -->\n",
237+
"<g id=\"edge2\" class=\"edge\">\n",
238+
"<title>Person-&gt;Fluency</title>\n",
239+
"<path fill=\"none\" stroke=\"#000000\" stroke-width=\"0.75\" stroke-opacity=\"0.250980\" d=\"M101.32,-70.8C95.03,-59.95 86.86,-45.87 80.59,-35.05\"/>\n",
240+
"</g>\n",
241+
"</g>\n",
242+
"</svg>"
243+
],
244+
"text/plain": [
245+
"<datajoint.diagram.Diagram at 0xffff53b2dfd0>"
246+
]
247+
},
248+
"execution_count": 3,
249+
"metadata": {},
250+
"output_type": "execute_result"
251+
}
252+
],
253+
"source": [
254+
"dj.Diagram(schema)"
255+
]
256+
},
193257
{
194258
"cell_type": "markdown",
195259
"metadata": {},
@@ -201,7 +265,7 @@
201265
},
202266
{
203267
"cell_type": "code",
204-
"execution_count": 3,
268+
"execution_count": 4,
205269
"metadata": {},
206270
"outputs": [
207271
{
@@ -294,7 +358,7 @@
294358
" (Total: 500)"
295359
]
296360
},
297-
"execution_count": 3,
361+
"execution_count": 4,
298362
"metadata": {},
299363
"output_type": "execute_result"
300364
}
@@ -331,7 +395,7 @@
331395
},
332396
{
333397
"cell_type": "code",
334-
"execution_count": 4,
398+
"execution_count": 5,
335399
"metadata": {},
336400
"outputs": [
337401
{
@@ -424,7 +488,7 @@
424488
" (Total: 1250)"
425489
]
426490
},
427-
"execution_count": 4,
491+
"execution_count": 5,
428492
"metadata": {},
429493
"output_type": "execute_result"
430494
}
@@ -457,7 +521,7 @@
457521
},
458522
{
459523
"cell_type": "code",
460-
"execution_count": 5,
524+
"execution_count": 6,
461525
"metadata": {},
462526
"outputs": [
463527
{
@@ -544,7 +608,7 @@
544608
" (Total: 11)"
545609
]
546610
},
547-
"execution_count": 5,
611+
"execution_count": 6,
548612
"metadata": {},
549613
"output_type": "execute_result"
550614
}
@@ -556,7 +620,7 @@
556620
},
557621
{
558622
"cell_type": "code",
559-
"execution_count": 6,
623+
"execution_count": 7,
560624
"metadata": {},
561625
"outputs": [
562626
{
@@ -643,7 +707,7 @@
643707
" (Total: 90)"
644708
]
645709
},
646-
"execution_count": 6,
710+
"execution_count": 7,
647711
"metadata": {},
648712
"output_type": "execute_result"
649713
}
@@ -655,7 +719,7 @@
655719
},
656720
{
657721
"cell_type": "code",
658-
"execution_count": 7,
722+
"execution_count": 8,
659723
"metadata": {},
660724
"outputs": [
661725
{
@@ -742,7 +806,7 @@
742806
" (Total: 6)"
743807
]
744808
},
745-
"execution_count": 7,
809+
"execution_count": 8,
746810
"metadata": {},
747811
"output_type": "execute_result"
748812
}
@@ -754,7 +818,7 @@
754818
},
755819
{
756820
"cell_type": "code",
757-
"execution_count": 16,
821+
"execution_count": 9,
758822
"metadata": {},
759823
"outputs": [
760824
{
@@ -853,7 +917,7 @@
853917
" (Total: 117)"
854918
]
855919
},
856-
"execution_count": 16,
920+
"execution_count": 9,
857921
"metadata": {},
858922
"output_type": "execute_result"
859923
}
@@ -865,7 +929,7 @@
865929
},
866930
{
867931
"cell_type": "code",
868-
"execution_count": null,
932+
"execution_count": 10,
869933
"metadata": {},
870934
"outputs": [
871935
{
@@ -957,7 +1021,7 @@
9571021
" (Total: 3)"
9581022
]
9591023
},
960-
"execution_count": 21,
1024+
"execution_count": 10,
9611025
"metadata": {},
9621026
"output_type": "execute_result"
9631027
}
@@ -969,7 +1033,7 @@
9691033
},
9701034
{
9711035
"cell_type": "code",
972-
"execution_count": null,
1036+
"execution_count": 11,
9731037
"metadata": {},
9741038
"outputs": [
9751039
{
@@ -1062,7 +1126,7 @@
10621126
" (Total: 196)"
10631127
]
10641128
},
1065-
"execution_count": 22,
1129+
"execution_count": 11,
10661130
"metadata": {},
10671131
"output_type": "execute_result"
10681132
}
@@ -1075,7 +1139,7 @@
10751139
},
10761140
{
10771141
"cell_type": "code",
1078-
"execution_count": null,
1142+
"execution_count": 12,
10791143
"metadata": {},
10801144
"outputs": [
10811145
{
@@ -1168,7 +1232,7 @@
11681232
" (Total: 28)"
11691233
]
11701234
},
1171-
"execution_count": 23,
1235+
"execution_count": 12,
11721236
"metadata": {},
11731237
"output_type": "execute_result"
11741238
}
@@ -1180,7 +1244,7 @@
11801244
},
11811245
{
11821246
"cell_type": "code",
1183-
"execution_count": 25,
1247+
"execution_count": 13,
11841248
"metadata": {},
11851249
"outputs": [
11861250
{
@@ -1272,7 +1336,7 @@
12721336
" (Total: 3)"
12731337
]
12741338
},
1275-
"execution_count": 25,
1339+
"execution_count": 13,
12761340
"metadata": {},
12771341
"output_type": "execute_result"
12781342
}

0 commit comments

Comments
 (0)