Skip to content

Commit 8600433

Browse files
Merge pull request dimitri-yatsenko#55 from dimitri-yatsenko/claude/reorganize-diagram-sections-YwHn8
Reorganize diagramming and relationships sections
2 parents a72d314 + decf35d commit 8600433

File tree

3 files changed

+14
-92
lines changed

3 files changed

+14
-92
lines changed

book/30-design/030-foreign-keys.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,8 +539,8 @@ CREATE TABLE order_ (
539539
`````
540540

541541
```{seealso}
542-
For detailed coverage of relationship patterns created by different foreign key placements, see [Relationships](050-relationships.ipynb).
543-
For visual representation of these relationships, see [Diagramming](060-diagrams.ipynb).
542+
To see how these foreign key placements appear in schema diagrams, see [Diagramming](040-diagrams.ipynb).
543+
For detailed coverage of relationship patterns, see [Relationships](050-relationships.ipynb).
544544
```
545545

546546
# Association Tables: Many-to-Many Relationships
@@ -647,6 +647,6 @@ In DataJoint, they also establish **workflow dependencies** that prescribe the o
647647
:class: note
648648
649649
Now that you understand foreign keys and their modifiers:
650+
- **[Diagramming](040-diagrams.ipynb)** — Learn to read and interpret schema diagrams
650651
- **[Relationships](050-relationships.ipynb)** — Explore relationship patterns: one-to-one, one-to-many, many-to-many
651-
- **[Diagramming](060-diagrams.ipynb)** — Learn to read and interpret schema diagrams
652652
```
Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,7 @@
44
"cell_type": "markdown",
55
"id": "cell-0",
66
"metadata": {},
7-
"source": [
8-
"---\n",
9-
"title: Diagramming\n",
10-
"---\n",
11-
"\n",
12-
"# Diagramming: Visualizing Schema Structure\n",
13-
"\n",
14-
"Schema diagrams are essential tools for understanding and designing DataJoint pipelines.\n",
15-
"They provide a visual representation of tables and their dependencies, making complex workflows comprehensible at a glance.\n",
16-
"\n",
17-
"As introduced in [Relational Workflows](../20-concepts/05-workflows.md), DataJoint schemas form **Directed Acyclic Graphs (DAGs)** where:\n",
18-
"\n",
19-
"- **Nodes** represent tables (workflow steps)\n",
20-
"- **Edges** represent foreign key dependencies\n",
21-
"- **Direction** flows from parent (referenced) to child (referencing) tables\n",
22-
"\n",
23-
"This DAG structure embodies a core principle of the Relational Workflow Model: **the schema is an executable specification**.\n",
24-
"Tables at the top are independent entities; tables below depend on tables above them.\n",
25-
"Reading the diagram top-to-bottom reveals the workflow execution order.\n",
26-
"\n",
27-
"```{admonition} Learning Objectives\n",
28-
":class: note\n",
29-
"\n",
30-
"By the end of this chapter, you will:\n",
31-
"- Understand the three line styles and their semantic meanings\n",
32-
"- Identify relationship types from diagram structure\n",
33-
"- Recognize what diagrams show and don't show\n",
34-
"- Use diagram operations to explore large schemas\n",
35-
"- Compare DataJoint notation with traditional ER diagrams\n",
36-
"```"
37-
]
7+
"source": "---\ntitle: Diagramming\n---\n\n# Diagramming: Visualizing Schema Structure\n\nSchema diagrams are essential tools for understanding and designing DataJoint pipelines.\nThey provide a visual representation of tables and their dependencies, making complex workflows comprehensible at a glance.\n\nBuilding on the [Foreign Keys](030-foreign-keys.md) chapter—which covered how foreign key placement affects relationship structure—this chapter focuses on how to **read and interpret** the visual representation of these relationships.\n\nAs introduced in [Relational Workflows](../20-concepts/05-workflows.md), DataJoint schemas form **Directed Acyclic Graphs (DAGs)** where:\n\n- **Nodes** represent tables (workflow steps)\n- **Edges** represent foreign key dependencies\n- **Direction** flows from parent (referenced) to child (referencing) tables\n\nThis DAG structure embodies a core principle of the Relational Workflow Model: **the schema is an executable specification**.\nTables at the top are independent entities; tables below depend on tables above them.\nReading the diagram top-to-bottom reveals the workflow execution order.\n\n```{admonition} Learning Objectives\n:class: note\n\nBy the end of this chapter, you will:\n- Understand the three line styles and their semantic meanings\n- Identify relationship types from diagram structure\n- Recognize what diagrams show and don't show\n- Use diagram operations to explore large schemas\n- Compare DataJoint notation with traditional ER diagrams\n```"
388
},
399
{
4010
"cell_type": "markdown",
@@ -1339,6 +1309,12 @@
13391309
"```"
13401310
]
13411311
},
1312+
{
1313+
"cell_type": "markdown",
1314+
"id": "azttpu2mrwk",
1315+
"source": "```{admonition} Next Steps\n:class: note\n\nNow that you can read and interpret schema diagrams:\n- **[Relationships](050-relationships.ipynb)** — Explore relationship patterns: one-to-one, one-to-many, many-to-many, hierarchies, and more\n- **[Master-Part Tables](053-master-part.ipynb)** — Special pattern for composite entities\n```",
1316+
"metadata": {}
1317+
},
13421318
{
13431319
"cell_type": "markdown",
13441320
"id": "cell-27",
@@ -1382,4 +1358,4 @@
13821358
},
13831359
"nbformat": 4,
13841360
"nbformat_minor": 5
1385-
}
1361+
}

book/30-design/050-relationships.ipynb

Lines changed: 3 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,7 @@
44
"cell_type": "markdown",
55
"id": "cell-0",
66
"metadata": {},
7-
"source": [
8-
"---\n",
9-
"title: Relationships\n",
10-
"---\n",
11-
"\n",
12-
"# Relationships: Modeling Entity Connections\n",
13-
"\n",
14-
"Relational databases model the real world by representing entities and the **relationships** between them.\n",
15-
"While the [Foreign Keys](030-foreign-keys.md) chapter covered how foreign keys enforce referential integrity, this chapter focuses on the **patterns** that emerge from different combinations of uniqueness and referential constraints.\n",
16-
"\n",
17-
"Understanding these patterns is essential for designing schemas that accurately represent business rules, data dependencies, and workflow structures.\n",
18-
"\n",
19-
"```{admonition} Learning Objectives\n",
20-
":class: note\n",
21-
"\n",
22-
"By the end of this chapter, you will:\n",
23-
"- Understand how foreign key placement determines relationship cardinality\n",
24-
"- Design one-to-one, one-to-many, and many-to-many relationships\n",
25-
"- Use association tables for complex relationships\n",
26-
"- Build hierarchies and sequences using cascading foreign keys\n",
27-
"- Apply the parameterization pattern for method/parameter combinations\n",
28-
"- Model directed graphs using renamed foreign keys\n",
29-
"```"
30-
]
7+
"source": "---\ntitle: Relationships\n---\n\n# Relationships: Modeling Entity Connections\n\nRelational databases model the real world by representing entities and the **relationships** between them.\nBuilding on the [Foreign Keys](030-foreign-keys.md) chapter—which covered referential integrity and foreign key modifiers—and the [Diagramming](040-diagrams.ipynb) chapter—which introduced the visual notation—this chapter focuses on the **patterns** that emerge from different combinations of uniqueness and referential constraints.\n\nUnderstanding these patterns is essential for designing schemas that accurately represent business rules, data dependencies, and workflow structures.\nThroughout this chapter, we'll use diagrams to visualize each pattern, reinforcing the connection between table definitions and their visual representation.\n\n```{admonition} Learning Objectives\n:class: note\n\nBy the end of this chapter, you will:\n- Understand how foreign key placement determines relationship cardinality\n- Design one-to-one, one-to-many, and many-to-many relationships\n- Use association tables for complex relationships\n- Build hierarchies and sequences using cascading foreign keys\n- Apply the parameterization pattern for method/parameter combinations\n- Model directed graphs using renamed foreign keys\n```"
318
},
329
{
3310
"cell_type": "markdown",
@@ -1967,38 +1944,7 @@
19671944
"cell_type": "markdown",
19681945
"id": "cell-37",
19691946
"metadata": {},
1970-
"source": [
1971-
"# Relationship Summary\n",
1972-
"\n",
1973-
"| Pattern | Foreign Key Position | Constraint | Cardinality | Diagram Line |\n",
1974-
"|---------|---------------------|------------|-------------|--------------|\n",
1975-
"| One-to-many (reference) | Secondary | None | 1:N | Dashed |\n",
1976-
"| One-to-many (containment) | Part of PK | None | 1:N | Thin solid |\n",
1977-
"| One-to-one (extension) | Entire PK | Inherent | 1:1 | Thick solid |\n",
1978-
"| One-to-one (reference) | Secondary | `unique` | 1:1 | Dashed |\n",
1979-
"| Optional relationship | Secondary | `nullable` | 1:0..N | Dashed |\n",
1980-
"| Optional one-to-one | Secondary | `nullable, unique` | 1:0..1 | Dashed |\n",
1981-
"| Many-to-many | Both in PK | None | M:N | Two thin solids |\n",
1982-
"\n",
1983-
"```{admonition} Design Guidelines\n",
1984-
":class: tip\n",
1985-
"\n",
1986-
"1. **Prefer solid lines** when appropriate—they enable direct joins across levels\n",
1987-
"2. **Use composite primary keys** for hierarchies to cascade identity\n",
1988-
"3. **Use association tables** for many-to-many relationships\n",
1989-
"4. **Use thick solid lines** (extension) when child has no independent meaning\n",
1990-
"5. **Check table definitions** for `nullable` and `unique`—diagrams don't show them\n",
1991-
"```\n",
1992-
"\n",
1993-
"```{admonition} Next Steps\n",
1994-
":class: note\n",
1995-
"\n",
1996-
"Now that you understand relationship patterns:\n",
1997-
"- **[Master-Part Tables](053-master-part.ipynb)** — Special pattern for composite entities\n",
1998-
"- **[Diagramming](060-diagrams.ipynb)** — Visual representation of relationships\n",
1999-
"- **[Normalization](055-normalization.ipynb)** — Principles for organizing attributes\n",
2000-
"```"
2001-
]
1947+
"source": "# Relationship Summary\n\n| Pattern | Foreign Key Position | Constraint | Cardinality | Diagram Line |\n|---------|---------------------|------------|-------------|--------------|\n| One-to-many (reference) | Secondary | None | 1:N | Dashed |\n| One-to-many (containment) | Part of PK | None | 1:N | Thin solid |\n| One-to-one (extension) | Entire PK | Inherent | 1:1 | Thick solid |\n| One-to-one (reference) | Secondary | `unique` | 1:1 | Dashed |\n| Optional relationship | Secondary | `nullable` | 1:0..N | Dashed |\n| Optional one-to-one | Secondary | `nullable, unique` | 1:0..1 | Dashed |\n| Many-to-many | Both in PK | None | M:N | Two thin solids |\n\n```{admonition} Design Guidelines\n:class: tip\n\n1. **Prefer solid lines** when appropriate—they enable direct joins across levels\n2. **Use composite primary keys** for hierarchies to cascade identity\n3. **Use association tables** for many-to-many relationships\n4. **Use thick solid lines** (extension) when child has no independent meaning\n5. **Check table definitions** for `nullable` and `unique`—diagrams don't show them\n```\n\n```{admonition} Next Steps\n:class: note\n\nNow that you understand relationship patterns:\n- **[Master-Part Tables](053-master-part.ipynb)** — Special pattern for composite entities\n- **[Normalization](055-normalization.ipynb)** — Principles for organizing attributes\n```"
20021948
},
20031949
{
20041950
"cell_type": "markdown",
@@ -2391,4 +2337,4 @@
23912337
},
23922338
"nbformat": 4,
23932339
"nbformat_minor": 5
2394-
}
2340+
}

0 commit comments

Comments
 (0)