Skip to content

Commit acd67f5

Browse files
Merge pull request #5 from dimitri-yatsenko/main
clean execution of the master-part chapter
2 parents 42a9b32 + 24adab8 commit acd67f5

File tree

2 files changed

+46
-27
lines changed

2 files changed

+46
-27
lines changed

book/30-database-design/053-master-part.ipynb

Lines changed: 45 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"cell_type": "markdown",
1212
"metadata": {},
1313
"source": [
14-
"Master-part relationships capture the idea that a given entity (*master*) may include several tightly-coupled component entities (*parts*) spread across multiple tables. \n",
14+
"Master-part relationships express the idea that a given entity (*master*) may include several tightly-coupled component entities (*parts*) spread across multiple tables. \n",
1515
"This notion is also described as *compositional integrity*.\n",
1616
"\n",
1717
"In DataJoint's relational workflow philosophy, a master part relationship expresses the notion of populated multiple related data artifacts in a single workflow step.\n",
@@ -44,14 +44,6 @@
4444
"text": [
4545
"Exception reporting mode: Minimal\n"
4646
]
47-
},
48-
{
49-
"ename": "ModuleNotFoundError",
50-
"evalue": "No module named 'datajoint'",
51-
"output_type": "error",
52-
"traceback": [
53-
"\u001b[0;31mModuleNotFoundError\u001b[0m\u001b[0;31m:\u001b[0m No module named 'datajoint'\n"
54-
]
5547
}
5648
],
5749
"source": [
@@ -64,16 +56,16 @@
6456
"@schema \n",
6557
"class Polygon(dj.Manual):\n",
6658
" definition = \"\"\"\n",
67-
" polygon_id : uint16\n",
59+
" polygon_id : int\n",
6860
" \"\"\"\n",
6961
"\n",
7062
" class Vertex(dj.Part):\n",
7163
" definition = \"\"\"\n",
7264
" -> master\n",
73-
" vertex_id : uint16 \n",
65+
" vertex_id : int \n",
7466
" ---\n",
75-
" x : float32\n",
76-
" y : float32\n",
67+
" x : float\n",
68+
" y : float\n",
7769
" \"\"\"\n",
7870
"\n",
7971
" # Explicit numeric datatypes such as float32 and uint16 are introduced in DataJoint 2.0.\n",
@@ -86,12 +78,44 @@
8678
"metadata": {},
8779
"outputs": [
8880
{
89-
"ename": "NameError",
90-
"evalue": "name 'dj' is not defined",
91-
"output_type": "error",
92-
"traceback": [
93-
"\u001b[0;31mNameError\u001b[0m\u001b[0;31m:\u001b[0m name 'dj' is not defined\n"
94-
]
81+
"data": {
82+
"image/svg+xml": [
83+
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"98pt\" height=\"98pt\" viewBox=\"0.00 0.00 98.00 98.00\">\n",
84+
"<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 94)\">\n",
85+
"<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-94 94,-94 94,4 -4,4\"/>\n",
86+
"<!-- Polygon -->\n",
87+
"<g id=\"node1\" class=\"node\">\n",
88+
"<title>Polygon</title>\n",
89+
"<g id=\"a_node1\"><a xlink:title=\"polygon_id           &#13;\">\n",
90+
"<polygon fill=\"#00ff00\" fill-opacity=\"0.188235\" stroke=\"#00ff00\" stroke-opacity=\"0.188235\" points=\"76.5,-90 13.5,-90 13.5,-55 76.5,-55 76.5,-90\"/>\n",
91+
"<text text-anchor=\"start\" x=\"21.5\" y=\"-70.4\" font-family=\"arial\" text-decoration=\"underline\" font-size=\"12.00\" fill=\"darkgreen\">Polygon</text>\n",
92+
"</a>\n",
93+
"</g>\n",
94+
"</g>\n",
95+
"<!-- Polygon.Vertex -->\n",
96+
"<g id=\"node2\" class=\"node\">\n",
97+
"<title>Polygon.Vertex</title>\n",
98+
"<g id=\"a_node2\"><a xlink:title=\"→ Polygon&#13;vertex_id            &#13;------------------------------&#13;x                    &#13;y                    &#13;\">\n",
99+
"<polygon fill=\"transparent\" stroke=\"transparent\" points=\"90,-19 0,-19 0,0 90,0 90,-19\"/>\n",
100+
"<text text-anchor=\"start\" x=\"8\" y=\"-8\" font-family=\"arial\" text-decoration=\"underline\" font-size=\"10.00\">Polygon.Vertex</text>\n",
101+
"</a>\n",
102+
"</g>\n",
103+
"</g>\n",
104+
"<!-- Polygon&#45;&gt;Polygon.Vertex -->\n",
105+
"<g id=\"edge1\" class=\"edge\">\n",
106+
"<title>Polygon-&gt;Polygon.Vertex</title>\n",
107+
"<path fill=\"none\" stroke=\"#000000\" stroke-width=\"0.75\" stroke-opacity=\"0.250980\" d=\"M45,-54.83C45,-43.26 45,-28.32 45,-19.08\"/>\n",
108+
"</g>\n",
109+
"</g>\n",
110+
"</svg>"
111+
],
112+
"text/plain": [
113+
"<datajoint.diagram.Diagram at 0xffff27979d30>"
114+
]
115+
},
116+
"execution_count": 3,
117+
"metadata": {},
118+
"output_type": "execute_result"
95119
}
96120
],
97121
"source": [
@@ -179,16 +203,11 @@
179203
"\n",
180204
"Master-part relationships provide a concise and expressive way to model a master record that owns several subordinate rows. DataJoint’s nested class syntax, simplified foreign key, and transactional populate make this pattern easy to express and safe to use. In the context of relational workflows, masters act as workflow nodes, while parts capture the detailed payload generated in the same workflow step.\n"
181205
]
182-
},
183-
{
184-
"cell_type": "markdown",
185-
"metadata": {},
186-
"source": []
187206
}
188207
],
189208
"metadata": {
190209
"kernelspec": {
191-
"display_name": "Python 3",
210+
"display_name": "base",
192211
"language": "python",
193212
"name": "python3"
194213
},
@@ -202,7 +221,7 @@
202221
"name": "python",
203222
"nbconvert_exporter": "python",
204223
"pygments_lexer": "ipython3",
205-
"version": "3.11.11"
224+
"version": "3.13.2"
206225
}
207226
},
208227
"nbformat": 4,

book/60-computation/010-computation.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"\n",
1414
"Some workflow steps are performed by extenal actions---we designate them as *manual* even if these extenal actions are automated by scripts and application. The tables for manual steps are populated using their `insert` methods directly. \n",
1515
"\n",
16-
"Automated steps are treated differently. Their `insert` method are never invoked directly and datajoint will raise an error if one will try to insert \n",
16+
"Automated steps are treated differently. Their `insert` method should never be invoked directly and DataJoint clients will raise an error if one will try to insert data directly into a computed table or its parts.\n",
1717
"\n",
1818
"\n",
1919
"\n",

0 commit comments

Comments
 (0)