+ "source": "# Diagram Operations\n\nDataJoint provides operators to filter and combine diagrams for exploring large schemas:\n\n```python\n# Show entire schema\ndj.Diagram(schema)\n\n# Show specific tables\ndj.Diagram(Table1) + dj.Diagram(Table2)\n\n# Show table and N levels of upstream dependencies\ndj.Diagram(Table) - N\n\n# Show table and N levels of downstream dependents\ndj.Diagram(Table) + N\n\n# Combine operations\n(dj.Diagram(Table1) - 2) + (dj.Diagram(Table2) + 1)\n\n# Intersection: show only common nodes between two diagrams\ndj.Diagram(Table1) * dj.Diagram(Table2)\n```\n\n## Finding Paths Between Tables\n\nThe intersection operator `*` is particularly useful for finding connection paths between two tables in a large schema.\nBy expanding one table downstream and another upstream, then taking the intersection, you reveal only the tables that form the path(s) between them:\n\n```python\n# Find all paths connecting table1 to table2 (where table2 is downstream from table1)\n(dj.Diagram(table1) + 100) * (dj.Diagram(table2) - 100)\n```\n\nThis works because:\n- `dj.Diagram(table1) + 100` includes table1 and up to 100 levels of downstream dependents\n- `dj.Diagram(table2) - 100` includes table2 and up to 100 levels of upstream dependencies\n- The intersection `*` shows only tables that appear in **both** diagrams—the connecting path(s)"
0 commit comments