Skip to content

Commit 200b0c4

Browse files
Merge pull request #139 from datajoint/feat/diagram-improvements
docs: Diagram guide with schema grouping, collapse, and Mermaid examples
2 parents 67fcc60 + 4f43fd0 commit 200b0c4

38 files changed

+6775
-2928
lines changed

mkdocs.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ nav:
5959
- Schema Design:
6060
- Define Tables: how-to/define-tables.md
6161
- Model Relationships: how-to/model-relationships.ipynb
62+
- Master-Part Tables: how-to/master-part.ipynb
6263
- Design Primary Keys: how-to/design-primary-keys.md
6364
- Read Diagrams: how-to/read-diagrams.ipynb
6465
- Project Management:
@@ -102,6 +103,7 @@ nav:
102103
- Semantic Matching: reference/specs/semantic-matching.md
103104
- Primary Keys: reference/specs/primary-keys.md
104105
- Fetch API: reference/specs/fetch-api.md
106+
- Diagram: reference/specs/diagram.md
105107
- Type System:
106108
- Types: reference/specs/type-system.md
107109
- Codec API: reference/specs/codec-api.md

scripts/execute-notebooks.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ export DJ_PASS=tutorial
1414
export DJ_BACKEND=postgresql
1515
export DJ_USE_TLS=false
1616

17+
# Display settings
18+
export DJ_DIAGRAM_DIRECTION=LR
19+
1720
echo "Executing tutorials with PostgreSQL backend..."
1821
echo " Host: $DJ_HOST:$DJ_PORT"
1922
echo " User: $DJ_USER"

src/assets/stylesheets/extra.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,29 @@
110110
Code Block Enhancements
111111
------------------------------------------------------------------- */
112112

113+
/* Smaller font and line wrapping for code blocks */
114+
.md-typeset code,
115+
.md-typeset pre > code,
116+
.md-typeset .highlight code,
117+
.md-typeset .highlighttable code {
118+
font-size: 0.7em !important;
119+
}
120+
121+
/* Also target Jupyter notebook code cells */
122+
.md-typeset .jp-CodeCell code,
123+
.md-typeset .cell_input code,
124+
.md-typeset .input_area code {
125+
font-size: 0.7em !important;
126+
}
127+
128+
.md-typeset pre,
129+
.md-typeset .highlight pre {
130+
/* Wrap long lines */
131+
white-space: pre-wrap;
132+
word-wrap: break-word;
133+
overflow-wrap: break-word;
134+
}
135+
113136
/* Add subtle visual distinction for code comparisons */
114137
.version-comparison {
115138
display: grid;

src/explanation/index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ and scalable.
4949
From workflows to complete data operations systems. Project structure and
5050
object-augmented schemas.
5151

52+
- :material-link-variant: **[Semantic Matching](semantic-matching.md)**
53+
54+
How DataJoint ensures safe joins through attribute lineage tracking.
55+
56+
- :material-new-box: **[What's New in 2.0](whats-new-2.md)**
57+
58+
Major changes, new features, and migration guidance for DataJoint 2.0.
59+
5260
- :material-frequently-asked-questions: **[FAQ](faq.md)**
5361

5462
How DataJoint compares to ORMs, workflow managers, and lakehouses.

src/how-to/define-tables.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,3 +350,10 @@ print(Session().describe())
350350
# Show heading
351351
print(Session().heading)
352352
```
353+
354+
## See Also
355+
356+
- [Master-Part Tables](master-part.ipynb) — Working with part tables
357+
- [Model Relationships](model-relationships.ipynb) — Foreign key patterns
358+
- [Design Primary Keys](design-primary-keys.md) — Key selection strategies
359+
- [Insert Data](insert-data.md) — Adding data to tables

src/how-to/delete-data.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ print(f"Deleted {count} subjects")
191191

192192
## See Also
193193

194+
- [Master-Part Tables](master-part.ipynb) — Compositional data patterns
194195
- [Model Relationships](model-relationships.ipynb) — Foreign key patterns
195196
- [Insert Data](insert-data.md) — Adding data to tables
196197
- [Run Computations](run-computations.md) — Recomputing after changes
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Demo modules for diagram collapse example
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"""
2+
acquisition.py - Data acquisition tables
3+
4+
This module defines the core acquisition schema with Subject and Session tables.
5+
Tables are declared but schema must be activated before use.
6+
"""
7+
import datajoint as dj
8+
9+
# Create schema without activating - caller must activate before use
10+
schema = dj.Schema()
11+
12+
13+
@schema
14+
class Lab(dj.Manual):
15+
definition = """
16+
lab : varchar(32)
17+
---
18+
institution : varchar(100)
19+
"""
20+
21+
22+
@schema
23+
class Subject(dj.Manual):
24+
definition = """
25+
subject_id : varchar(16)
26+
---
27+
-> Lab
28+
species : varchar(50)
29+
sex : enum('M', 'F', 'U')
30+
"""
31+
32+
33+
@schema
34+
class Session(dj.Manual):
35+
definition = """
36+
-> Subject
37+
session_date : date
38+
---
39+
session_notes : varchar(1000)
40+
"""
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
"""
2+
analysis.py - Analysis tables
3+
4+
This module defines analysis tables that aggregate results across sessions.
5+
Tables are declared but schema must be activated before use.
6+
"""
7+
import datajoint as dj
8+
from . import acquisition, processing
9+
10+
# Create schema without activating - caller must activate before use
11+
schema = dj.Schema()
12+
13+
14+
@schema
15+
class AnalysisParams(dj.Lookup):
16+
definition = """
17+
analysis_id : int16
18+
---
19+
method : varchar(50)
20+
"""
21+
contents = [(1, 'correlation'), (2, 'regression')]
22+
23+
24+
@schema
25+
class SubjectAnalysis(dj.Computed):
26+
definition = """
27+
-> acquisition.Subject
28+
-> AnalysisParams
29+
---
30+
result : float32
31+
confidence : float32
32+
"""
33+
34+
def make(self, key):
35+
self.insert1({**key, 'result': 0.8, 'confidence': 0.95})
36+
37+
38+
@schema
39+
class CrossSessionAnalysis(dj.Computed):
40+
definition = """
41+
-> acquisition.Subject
42+
-> processing.ProcessingParams
43+
---
44+
aggregate_score : float32
45+
"""
46+
47+
def make(self, key):
48+
self.insert1({**key, 'aggregate_score': 0.9})
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"""
2+
processing.py - Data processing tables
3+
4+
This module defines computed tables that process raw acquisition data.
5+
Tables are declared but schema must be activated before use.
6+
"""
7+
import datajoint as dj
8+
from . import acquisition
9+
10+
# Create schema without activating - caller must activate before use
11+
schema = dj.Schema()
12+
13+
14+
@schema
15+
class ProcessingParams(dj.Lookup):
16+
definition = """
17+
params_id : int16
18+
---
19+
filter_cutoff : float32
20+
threshold : float32
21+
"""
22+
contents = [(1, 30.0, 2.5), (2, 50.0, 3.0)]
23+
24+
25+
@schema
26+
class ProcessedSession(dj.Computed):
27+
definition = """
28+
-> acquisition.Session
29+
-> ProcessingParams
30+
---
31+
n_events : int32
32+
quality_score : float32
33+
"""
34+
35+
def make(self, key):
36+
self.insert1({**key, 'n_events': 100, 'quality_score': 0.95})
37+
38+
39+
@schema
40+
class EventDetection(dj.Computed):
41+
definition = """
42+
-> ProcessedSession
43+
event_id : int32
44+
---
45+
event_time : float32
46+
amplitude : float32
47+
"""
48+
49+
def make(self, key):
50+
pass

0 commit comments

Comments
 (0)