You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Add section 2.5 "Singleton Tables (Empty Primary Keys)" to table-declaration.md
- Update university tutorial with CurrentTerm singleton example
- Remove deprecated `___` separator mention (only `---` is supported)
Related to datajoint/datajoint-python#1341Closesdatajoint/datajoint-python#113
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
"[2026-01-17 00:50:04,016][WARNING]: Native type 'year' is used in attribute 'term_year'. Consider using a core DataJoint type for better portability.\n"
192
-
]
193
-
}
194
-
],
195
-
"source": [
196
-
"@schema\n",
197
-
"class Term(dj.Manual):\n",
198
-
" definition = \"\"\"\n",
199
-
" term_year : year\n",
200
-
" term : enum('Spring', 'Summer', 'Fall')\n",
201
-
"\"\"\""
202
-
]
170
+
"outputs": [],
171
+
"source": "@schema\nclass Term(dj.Manual):\n definition = \"\"\"\n term_year : int16\n term : enum('Spring', 'Summer', 'Fall')\n\"\"\"\n\n\n@schema\nclass CurrentTerm(dj.Lookup):\n definition = \"\"\"\n # Active registration term (singleton)\n ---\n -> Term\n\"\"\""
"source": "# Academic terms 2020-2024\nTerm.insert(\n {'term_year': year, 'term': term}\n for year in range(2020, 2025)\n for term in ['Spring', 'Summer', 'Fall']\n)\n\n# Set the current registration term (singleton - only one row allowed)\nCurrentTerm.insert1({'term_year': 2024, 'term': 'Fall'})\nprint(f\"Current term: {CurrentTerm.fetch1()}\")\n\n# Create sections for each course-term with 1-3 sections\nfor course in Course.keys():\n for term in Term.keys():\n for sec in 'abc'[:random.randint(1, 3)]:\n if random.random() < 0.7: # Not every course every term\n Section.insert1({\n **course, **term,\n 'section': sec,\n 'auditorium': f\"{random.choice('ABCDEF')}\"\n f\"{random.randint(100, 400)}\"\n }, skip_duplicates=True)\n\nprint(f\"{len(Section())} sections created\")"
704
644
},
705
645
{
706
646
"cell_type": "code",
@@ -2369,6 +2309,14 @@
2369
2309
"all_a"
2370
2310
]
2371
2311
},
2312
+
{
2313
+
"cell_type": "code",
2314
+
"id": "20yuzwslxgm",
2315
+
"source": "# Sections available in the current term (using singleton)\nSection & CurrentTerm",
0 commit comments