Mayo Clinic College of Medicine and Science is a graduate-only institution in IPEDS. It also enrolled 309 undergraduates in fall 2024.
Is that an error in the data, or an error in what I assumed “graduate-only” means?
It was my assumption. This is the ninth experiment in a series that uses one public dataset, NCES IPEDS 2024, to show how languages and models change what a knowledge graph says. Experiment 8 checked website claims against the data. This one checks the data against a set of written rules. The code, data and results are all on GitHub.
What we built
SHACL is the W3C language for validating RDF graphs. You write “shapes” that say what the data should look like, and a validator reports every node that breaks one.
We built one graph of the whole dataset: 45 institutions, their prices, admissions, enrollment, outcomes and 8,034 program offerings. That came to 115,257 triples in schema.org plus a small custom vocabulary. The mapping writes what the CSVs say and fixes nothing. A URL without https:// stays that way.
Then we wrote 28 shapes. Sixteen use core SHACL, such as required properties, datatypes and patterns. Twelve use SPARQL-based constraints for arithmetic and conditions across fields.
Each shape has a severity:
- Violation (red): the data is wrong or can’t be joined. A graduation rate of 104%. A count that doesn’t add up.
- Warning (amber): something expected is missing, or two sources disagree and a person has to look.
- Info (blue): worth knowing, but not a defect.
See it: every school, colored by what failed
In the visualization below, filter by severity and by kind of result. Click any school or constraint to see why it failed, or switch to the shapes as first written.
Open the visualization in a new tab
Results: no violations, 1,369 results
The final shapes found no Violations. They did report 1,328 Warnings and 41 Info results.
| Shape | Severity | Results | Reading |
|---|---|---|---|
| CIP term has a title | Warning | 1,065 | Documented gap |
| Admissions, aid and other office URLs are absolute | Warning | 95 (27 schools) | Data problem |
| Institution names its accreditor | Warning | 45 | Documented gap |
| Meal plan code has a decoded label | Warning | 45 | Documented gap |
| All-programs-distance code has a decoded label | Warning | 45 | Documented gap |
| Field label verified against the IPEDS dictionary | Info | 34 | Documented gap |
| Homepage URL is absolute | Warning | 25 | Documented gap |
| Published tuition and fees within 10% of its components | Warning | 6 (2 schools) | Data problem |
| Graduate-only schools: undergraduate students or certificates | Info | 4 (2 schools) | Note |
| Award-level flags have at least one program row | Info | 3 (3 schools) | Note |
| Graduate-only schools offer no undergraduate degrees | Warning | 1 | Data problem |
| Award levels with programs are listed in the school’s flags | Warning | 1 | Data problem |
| 16 other shapes | 14 Violation, 2 Warning | 0 | Pass |
Three kinds of red
A list of 1,369 failures isn’t useful on its own. Sorting them is.
Documented gaps: 1,259 results. These fail because the dataset’s README says they will. No school has an accreditor yet, because that source isn’t joined. None of the 1,065 CIP codes has a title. Two fields are raw codes with no labels. The shapes carry a note quoting the README, and the run fails if any of them stops firing. That way the documentation and the data can’t drift apart silently.
Data problems: 103 results. Nothing documents these.
- 95 office URLs without a scheme, at 27 schools. In
schema:url,www.asu.edu/is a relative URL. A consumer resolves it against whatever page it sits on. - Touro University California says it offers an associate’s degree. IPEDS also categorizes it as graduate-only with no undergraduate degrees. One of those two codes is wrong.
- Brigham Young University has a program row at an award level its own flags don’t list. Two IPEDS surveys disagree.
- Mayo Clinic College’s published undergraduate tuition and fees is $3,257. Its average tuition plus required fees is $9,040.
Notes: 7 results. Mayo’s 309 undergraduates are here, along with a few award-level flags that have no matching program rows.
Two shapes I had to relax
Two of my first shapes were wrong. Between them they produced 79 Violations, and none of those were data errors.
Graduate-only schools. My first shape said a graduate-only school carries no undergraduate data at all. It produced 55 Violations on Mayo and Touro. Then I read the category label again. It says “no undergraduate degrees,” not “no undergraduates.” Certificates aren’t degrees. The rule became three shapes, each with the severity its failure deserves: no undergraduate outcome rates (Violation), no undergraduate degree levels (Warning) and undergraduate students or certificates (Info).
Tuition. My first shape said published tuition and fees equals average tuition plus required fees, within $1. It produced 24 Violations at 8 schools. The data dictionary labels one “published” and the other “average.” They’re different IPEDS measures, so equality isn’t a rule. The final shape warns when they differ by more than 10%, which leaves Mayo and one other school.
I kept both first drafts in the repo. The 10% threshold is a judgment call, and I’d rather show it than hide it.
Does every passing shape bite?
A shape that never fires might be a shape that can’t fire. So we tested the 16 shapes that passed.
We took a four-school copy of the graph and seeded one defect per shape: a graduation rate of 104, more admits than applicants, a price with no currency, and an ID read as a number so that 00108100 became 108100. That last one is what a type-guessing CSV reader does. The right shape caught the right defect on the right node, 16 of 16.
SHACL, JSON Schema and the Rich Results Test
This comparison is conceptual. We didn’t run anything through JSON Schema or Google.
- JSON Schema validates one document’s shape: required keys, types, patterns and ranges. It can’t follow links between documents, and it checks the JSON, not the meaning.
- Google’s Rich Results Test checks markup against the properties Google requires for the rich result types it supports. It doesn’t know your business rules. As far as I know, there’s no rich result type for a college’s tuition or graduation rate, and none of these checks would flag a 104% graduation rate.
- SHACL validates the graph itself, with your own rules, at the severity you choose. The cost is writing and maintaining the shapes.
More on the other options is in our guide to structured data testing tools.
What this means for your structured data
Passing a validator tells you the markup is well-formed. It doesn’t tell you the numbers are right. In my experience, that gap is where most structured data problems live, because nobody owns the question “is this value plausible?”
A few practical takeaways:
- Treat shapes like unit tests. Run them on every build, expect documented gaps to fail and fail the build on Violations.
- Give every rule a severity. Not every failure is an emergency. A missing accreditor and a 104% graduation rate shouldn’t look the same in a report.
- Sort the results before you fix anything. Here, 92% of the results were gaps we already knew about. The 103 that mattered would have been easy to miss in the pile.
- Test your tests. Seed a defect and confirm the rule catches it.
Pro tip: When a rule fails on real data, check the rule before you blame the data. Two of my 28 shapes encoded an assumption the source never made.
Simply put, validation is only as good as the rules behind it. Writing those rules down is how you find out which of your assumptions were wrong. And a wrong number published as structured data gets quoted by search engines and LLMs as fact.
Run it yourself
Everything behind this post is in the Experiment 9 folder on GitHub. That includes the build script, all 28 shapes with the two first drafts, a sample validation report for one school and the full results. The run takes about 35 seconds.
Next in the series: linking all 45 institutions to Wikidata, and why matching by ID isn’t as clean as it sounds.
