Instructor guide¶
This guide helps you teach the ddigraph training curriculum in a classroom, a workshop or an online session. Learners who work alone can read it too, for the advice it gives on each module.
In a class or alone¶
The course works both ways:
- In a class. You show each idea live, then the learners do the exercises. Use the times and the tips below.
- Alone. Learners read each module, run its code, and check their work against the answer under each exercise, or the answer keys.
Suggested schedules¶
Each row adds up the times the modules give, without breaks or setup, as the course overview does.
| Format | Modules | Instructor-led | Self-paced | Covers |
|---|---|---|---|---|
| Half-day workshop | 1–4 | 3 h 15 min | 2 h 15 min | What DDI is, setup, a first look at a file, and the graph model |
| Full-day workshop | 1–7 | 6 h 30 min | 4 h 40 min | All of Tier 1, up to a first load into Neo4j |
| Three-day intensive | 1–16 | 15 h 50 min, about 5 h 20 min a day | 11 h 40 min | Tiers 1 and 2, with the capstone |
| Backend day | your pick of 17–23 | up to 7 h 10 min | up to 5 h 20 min | The tracks for the backends you use |
| Self-paced | 1–23, one module per session | 17 h | 23 sessions of 30 to 60 min, about 4 to 6 weeks |
Using the learning objectives¶
Each module opens with numbered learning objectives (O1, O2, ...). It tags each exercise and quiz question with the objectives it practises, and ends with a Check yourself list, one line per objective. Use them to run each session:
- Open with the objectives. Read them aloud, or show the box, at the start. The learners then know what they will be able to do by the end, and you know what to check.
- Pick exercises by tag. Short on time? Choose one exercise for each objective, not the first few in the list. If a learner struggles with an objective, give them another exercise with the same tag.
- Close with Check yourself. In the last five minutes, the learners tick the lines they can do. A line that many leave unticked tells you what to go over at the start of the next session. In Module 16, the rubric and the short talk do the same job.
The course's sample survey¶
Most examples use one survey: a fictional Labour Force Survey for the third quarter of 2025, by a "National Statistics Office". It is made up, but it follows the logic of a real one. It has eight questions with routing, seven variables, and code lists with their full set of categories. For example, labour force status is derived from three questions, as the ILO defines it. The repository holds it in four files:
| File | What it holds |
|---|---|
tests/fixtures/lfs_codebook.xml |
The survey in DDI-Codebook 2.6 |
tests/fixtures/lfs_lifecycle.xml |
The survey in DDI-Lifecycle 3.3, with its questionnaire |
tests/fixtures/lfs_cdi.xml |
The survey's variables and code lists in DDI-CDI 1.0 |
tests/fixtures/lfs_correspondence.xml |
Age groups mapped to broad age groups, and ISCED 1997 mapped to ISCED 2011, in DDI-CDI 1.0 |
The other files in tests/fixtures/ are small test files. A module uses
one only to show an edge case, such as a broken or invalid file, and says
so. Do not present them as surveys.
Setup checklist¶
Before the first session, check that each learner has:
- Python 3.12 or newer, and a terminal
- ddigraph installed with the extras the course uses:
pip install "ddigraph[all]", oruv syncin a clone - A clone of the repository, opened at its root, so that the
tests/fixtures/...paths work - A text editor or IDE
- For Module 7 and the server tracks: Docker, or a free Neo4j Aura account for Neo4j
You can run the servers once for the whole class instead. Start Neo4j 5,
PostgreSQL 18 and Gremlin Server 3.8.2 on one machine, as
Module 2 shows, and give each learner the addresses.
Then ask each learner to use their own dataset IDs, such as m07-ana, so
that two learners never replace each other's data.
Never point a class at a database you care about
The modules load, replace and purge datasets, and some scripts remove what an earlier run wrote. Use a new, empty Neo4j for the course, never one that holds real work.
Have a plan B: a cloud notebook or a container with everything installed. Modules 1 to 6 and the NetworkX, pandas, DuckDB and Oxigraph parts need no server, so a class can carry on while you fix one.
Tips for each module¶
Module 1: What DDI metadata is, and why a graph¶
- Start with a data file and no metadata. Ask the room what they would need to know to use it, before you define metadata.
- Draw one question, its variable and its code list on the board as boxes and arrows. That drawing is the graph the rest of the course builds.
- If the room knows DDI, spend the time on section 4: how a DDI-L file writes a link as a reference to a URN.
Module 2: Set up your environment¶
- Allow the whole slot. Setup is where a class loses the most time.
- The most common trouble is a path: learners who run the code outside the
clone's root get "file not found" for
tests/fixtures/.... - Start the servers in this session, even though Module 7 is the first to use them. Images take a while to download on a slow network.
Module 3: Look before you load¶
- Run
ddigraph previewon the projector on a file nobody has seen, and ask the room to guess its flavor from the counts. - Section 4 is the lesson: a count that looks right does not prove the
file was read right. Show
--limiton a sample. - Open the HTML page that
--format htmlwrites, in a browser.
Module 4: Nodes, edges and identity¶
- This is the model every later module uses. Go slowly.
- Put one node on the board with its six fields. Then show that two files
that name the same URN give the same
key. - Stubs surprise people. Explain that a stub is not an error: it records a reference the file makes but does not hold.
Module 5: Ask the graph questions in memory¶
- Build the first query live, one pattern at a time, and run it after each step.
- The code-list question of section 7 comes back in Modules 9, 17 and 22. Make sure everyone leaves with the two shapes clear.
- The NetworkX and pandas tabs show the same answer with other tools. Point
them out, but keep the session on
ddigraph.query.
Module 6: Prove it is right: XSD and SHACL¶
- Put the two questions side by side: "is the file valid DDI?" is the XSD; "is the graph well formed?" is SHACL.
- Most sample files fail the XSD on purpose, because they are small. Say so before anyone runs it, or the room will think something is broken.
- Install the
shaclextra before the session.
Module 7: Your first graph database: Neo4j¶
- Load a file on the projector, then open Neo4j Browser and let the room click through the graph.
- Show that a second load with
--replaceleaves the same counts. Loads are safe to repeat. - The Gremlin, PostgreSQL, DuckDB and Oxigraph tabs show the same steps elsewhere. Neo4j is the one to teach here.
Module 8: Linked data: RDF out and back in¶
- Show one node in Turtle before any SPARQL. Point at its two
rdf:types. - Learners who know RDF will ask why both types: one is the published term (DISCO, SKOS), the other is ddigraph's own.
Module 9: Code lists and classifications: SKOS and XKOS¶
- Draw the two DDI-L shapes, with codes and without, before you show the
CONTAINS*0..1path. The path makes sense once people see both. - For a statistical office, bring a classification the room uses, and ask how its levels and correspondences would look in XKOS.
Module 10: One query, many engines¶
- Run the same query in each tab, and show that the rows match.
- Then show the compiled text side by side: Cypher, SQL and SPARQL. The point is that the query is written once.
- Section 6 has the rules that surprise people: rows are a multiset, a missing value is unknown, and a limit needs an order.
Module 11: Reload, history and differences¶
- Load a file, change one label in a copy, load the copy, and show the diff. A small change gives a small diff.
- For archivists, connect generations to the versions of a survey they keep.
Module 12: Build your own pipeline and lens¶
- For developers. Others can skim it.
- Write section 4's one-pass loop live first. Then turn it into a lens with the four methods of section 6, and show that it reads back what it wrote.
Module 13: Big, broken and untrusted files¶
- Break a file on purpose in front of the room, by deleting one closing tag, and read it in both modes.
- Stress the safety rule: lift the limits with
huge_treeonly for a file you trust.
Module 14: Ground a language model in the graph¶
- No API key is needed for most of the module. Only one call reaches a model, and learners can skip it.
- Ask the room what a model would answer about a survey it has never seen. Then show how the pack changes the answer.
Module 15: Give a model tools over the graph¶
- Walk through one model turn by hand, on the board: the
tool_use, your function, then thetool_result. - End with section 6: when a pack is enough, and when a tool is better.
Module 16: Capstone projects¶
- Let each learner pick a track. In a mixed group, make teams by role.
- Ask to see each plan before anyone writes code.
- Let each learner pick their backend in the tabs. Keep time for short talks at the end.
Module 17: Neo4j in depth¶
- For people who will run ddigraph against Neo4j in production.
- The store (section 7) and
ddigraph repair(section 8) are what they will need most. Spend time there. neo4j-admin importneeds a Neo4j you manage yourself. On Aura, show the export step only.
Module 18: NetworkX¶
- No server. A good track for analysts.
- Ask the room to guess the most connected node before they compute it.
Module 19: pandas¶
- No server. A good track for analysts who live in tables.
- Show a join between the node and relationship tables, then write it to
Excel. Excel needs openpyxl, which the
pandasextra installs.
Module 20: SQL with DuckDB and PostgreSQL¶
- DuckDB runs with no server, so start there. PostgreSQL is the same lens on a server.
- SQL/PGQ needs the duckpgq extension, which a locked-down network may not reach. Download it before the session, or skip that part.
Module 21: RDF and SPARQL with Oxigraph¶
- No server: Oxigraph runs inside Python.
- Section 7, on language tags, is short but matters for French and English labels.
Module 22: Gremlin¶
- Start with section 3: ddigraph only writes to Gremlin. Learners query it with their own traversals.
- The Neo4j tabs show the same question in Cypher. Compare the two side by side.
Module 23: Serve the graph: HTTP and Arrow Flight¶
- Run
ddigraph serveon the projector, and open its/docspage before any code. - Arrow Flight is for people who move large tables between programs. Skip it for a general audience.
Common mistakes¶
| Mistake | Module | Fix |
|---|---|---|
| Running the code outside the clone's root | 2 onwards | cd to the clone; the paths start with tests/fixtures/ |
| Reading a good count as proof of a good read | 3 | Print samples with --limit |
| Taking a stub for an error | 4 | A stub records a reference the file does not hold |
Using q.edge before its nodes are bound |
5, 10 | Put each q.node before the q.edge that uses it |
| Reading an XSD failure on a sample file as a bug | 6 | The samples are small on purpose; read the issues |
| Looking for categories only under the code list | 9 | Use the CONTAINS*0..1 then HAS_CATEGORY path |
| Asking for a limit with no order | 10 | Add order_by, or the rows can change |
| Lifting the XML limits for every file | 13 | Use huge_tree only for a file you trust |
Expecting ddigraph.query to read Gremlin, NetworkX or pandas |
10, 18, 19, 22 | Ask them with their own tools |
| Two learners loading the same dataset ID | 7 onwards | Give each learner their own IDs |
Adapting for each audience¶
| Audience | Stress | Skip or skim |
|---|---|---|
| Archivists and data managers | Modules 1, 3, 4, 6, 8, 9 and 11 | Modules 12, 13 and 23 |
| Survey methodologists | Modules 4, 5 and 9, then 14 | Modules 12, 13 and the server tracks |
| Data engineers | Modules 7, 11, 12 and 13, then your backend's track | Module 1 |
| Developers | Modules 4, 10, 12 and 13, then 15 and 23 | Modules 1 and 3 |
| Analysts | Modules 4 and 5, then 18, 19 and 20 | Modules 12, 13 and 17 |
Assessment¶
- Quizzes (every module): to check understanding as you go. In a class, go over the answers together.
- Check yourself (every module): an exit ticket at the end of each session. See Using the learning objectives.
- Capstone (Module 16): the final test. Its rubric scores the module's objectives on one dataset, the plan and the talk included.
Words in English and French¶
| English | French |
|---|---|
| Metadata | Métadonnées |
| Graph | Graphe |
| Node | Nœud |
| Edge, relationship | Arête, relation |
| Key | Clé |
| Identity | Identité |
| Stub | Nœud provisoire |
| Code list | Liste de codes |
| Category | Catégorie |
| Classification | Classification |
| Lens | Lentille |
| Store | Dépôt |
| Backend | Moteur |
| Query | Requête |
| Validate | Valider |
| Shape (SHACL) | Forme (SHACL) |
| Dataset | Jeu de données |
| Grounding pack | Dossier d'ancrage |
Collecting feedback¶
After the last session:
- Ask the learners to fill in a short form, with three to five questions.
- Hold a ten-minute review: what worked, what did not, and what to change next time.
- Report a mistake in a module as an issue on the repository.
More resources¶
- Course overview: the modules, their times and prerequisites
- Cheat sheet: the commands and Python calls on one page
- Answer keys: every exercise and quiz answer on one page