rdfs:domain and rdfs:range

Let predicates classify their subjects and objects.

0/3 done

Theory

RDFS reads rdfs:domain and rdfs:range as typing rules, not constraints:

:teaches rdfs:domain :Master ;
         rdfs:range  :Ninja .

From :Splinter :teaches :Donatello ., a reasoner entails :Splinter a :Master . and :Donatello a :Ninja .. Surprising at first!

RDFS infers, it doesn't reject. Coming from SQL or OO languages, your instinct is to read rdfs:domain :Master as the subject must already be a :Master. RDFS does the opposite: it concludes the subject is a Master because you used :teaches. So an unintended :teaches use will silently classify the wrong thing as a :Master. To actually reject bad data, you'll want a SHACL shape (Level 6).

Analogy

RDFS treats rdfs:domain and rdfs:range as inference rules, not validation rules.

That means the graph does NOT ask:

“Is this already a :Master?”

Instead, it concludes:

“Because this entity used the :teaches relationship, it MUST be a :Master.”

The Movie Casting Analogy

Imagine a movie production database.

The system contains this rule:

:teaches rdfs:domain :Master ;
         rdfs:range  :Ninja .

This means:

  • whoever performs the action :teaches is inferred to be a :Master
  • whoever receives the action is inferred to be a :Ninja

Now suppose someone accidentally enters:

:Pizza :teaches :Donatello .

The reasoner does NOT reject it.

Instead, it silently concludes:

:Pizza a :Master .
:Donatello a :Ninja .

Why This Feels Strange

If you come from SQL or object-oriented programming, your instinct is:

“Only Masters are allowed to teach.”

But RDF/RDFS thinks differently.

RDFS says:

“If something teaches, then it is a Master.”

The relationship itself becomes evidence for classification.

The Uniform Analogy

Think of predicates like uniforms in a school.

If someone walks into the building wearing a teacher uniform, the security guard assumes:

“That person is a teacher.”

The system does not verify credentials first.

The action or role automatically classifies the entity.

In RDF:

Predicate UsedWhat the Graph Infers
:teachessubject is a :Master
:teachesobject is a :Ninja

Example

:Splinter :teaches :Donatello .

Automatically entails:

:Splinter a :Master .
:Donatello a :Ninja .

Important Distinction

Technology StyleMeaning of "domain"
SQL / OOPRestriction or validation
RDFSInference rule

RDFS does not reject bad data.

It expands the graph with new inferred facts.

The Hidden Danger

A mistaken relationship can silently misclassify things.

For example:

:CoffeeMachine :teaches :Alice .

would infer:

:CoffeeMachine a :Master .

which is probably nonsense.

Where SHACL Fits

If you actually want to reject invalid data, you need SHACL.

RDFS says:

“I will infer types from relationships.”

SHACL says:

“I will validate whether the graph obeys the rules.”

Mental Model

Think of RDFS as an automatic classifier.

Predicates behave like semantic clues.

When the graph sees a relationship, it uses that relationship to infer what kinds of things the subject and object must be.

Key Insight

rdfs:domain and rdfs:range are not guardrails.

They are type-generating inference rules.

Using a predicate teaches the graph how to classify the connected entities.

Reading in progress · 0 of 3 activities done