What Sandwiches Taught me About Ontologies

When I first heard we would be building an ontology about sandwiches in my Taxonomies and Metadata course, I assumes it was a metaphor.

It wasn’t.

By the end of the workshop, I realized the sandwich wasn’t a joke example at all and it was actually the perfect way to understand how machines learn meaning and why taxonomies alone are no longer enough.

From categories to meaning

At a first glance, sandwiches seem like they would be easy to categorise:

  • Bread
  • Filling
  • Sauce
  • Vegetables

That is a taxonomy. It’s clean. It’s hierarchical. It’s comfortable.

But the moment a user wants something like “a gluten-free pescatarian sandwich under 500 calories wirh salmon”, the hierarchy collapses.

And that is where ontologies begin.

Instead of just sorting things into boxes, ontologies model relationships.

It’s not about what something is, but rather how things connect.

Thinking in classes rather than labels

In our sandwich ontology, we stopped treating “sandwich” as a word and started treating it as a class.

A sandwich:

  • hasBread
  • hasFilling
  • hasSauce
  • hasVegetable
  • hasDietaryType

Each of those isn’t just text, it’s a relationship.

Bread itself becomes a class and so does the filling, and the dietary type. Suddenly, “gluten-free” isn’t marketing copy anymore. Now it’s a data property. And that shifts everything.

Why properties matter more than you think

One of the biggest mindset shifts was learning the difference between:

  • Object properties (sandwich hasBread sourdough)
  • Data properties (bread isGlutenFree = true)

This kind of a distinction is what allows machines to reason. A system doesn’t need to be told explicitly that a sandwich is gluten-free, it can infer it, based on the properties of the components.

That’s not automation.

That’s understanding.

Personalization is a semantic problem

The stated goal of the sandwich ontology was simple:

Make online sandwich ordering easier and more personalised.

But what we were really building was a semantic layer.

The layer allows:

  • dietary filtering
  • intelligent recommendations
  • meaningful search
  • scalable personalziation

Without it, “vegan”, “plant based”, and “dairy free” remain disconnected words. With it, however, they become linked concepts that machines can navigate with more confidence.

And this is the same logic behind:

  • content personalization
  • product recommendations
  • AI-powered search
  • adaptive user experiences

Just…less delicious.

Now, why does this matter beyond sandwiches?

The sandwich example works because it exposes the universal truth:

There is no machine intelligence without knowledge representation.

Ontologies translate the human view of the world into something machines could reason with. They sit between messy reality and artificial intelligence.

And crucially, they push us to ask better questions:

  • What relationships actually matter?
  • What properties are meaningful?
  • Where should we not over-model?

Good ontologies aren’t about capturing everything. Rather, they are about capturing just enough meaning to be useful.

Leave a comment