From W3C Wiki
Jump to: navigation, search

Inverse Properties in Web Schemas

It has been recently argued on the W3C public-vocabs mailing list that

  1. some properties are needed in both directions (e.g. the relationhip between Person and CreativeWork as both CreativeWork hasCreator Author and Author isCreatorOf CreativeWork), and
  2. that this should be addressed at the level of syntaxes for Web data, and not by defining inverse properties in the vocabularies.

In the following discussion, many relevant use-cases have been documented in which existing schema.org properties are needed in the opposite direction (see below for examples).

Support in Relevant Syntaxes

RDFa, JSON-LD, and Turtle

In RDFa, JSON-LD, and Turtle (and likely other syntaxes in use for Web vocabularies), there are mechanisms in place that allow for using the same property in both directions, i.e. the primary direction, for which the property is defined in the original vocabulary, and the reverse direction (effectively swapping subject and object):

  • RDFa: @rev vs. @rel
  • JSON-LD: @reverse keyword, as defined in http://www.w3.org/TR/json-ld/#reverse-properties.
  • Turtle: Use of a separate statement <subject> <predicate> <object>. (Note using a property with the current node as the object of a statement is limited for BNodes - it is only possible for labeled blank nodes (_:node123), not for unlabeled blank nodes.


As of today, Microdata does not support a similar mechanism. The only two currently supported patters are to use @itemref, @itemid, or a combination of both.

Example with @itemref

<!-- Example of using http://schema.org/creator from the position of the creator -->
<div itemscope itemtype="http://schema.org/CreativeWork" itemref="creator">
    <!-- Freebase URI for Romeo and Juliet -->
    <link itemprop="sameAs" href="http://www.freebase.com/m/0yq9mqd">
<div id="creator" itemprop="creator" itemscope itemtype="http://schema.org/Person">
    <span itemprop="name">William Shakespeare</name>

Example with @itemid

The @itemid attribute can be used to to create global identifiers for the object entity of the statement, to which we can then link to from the locally defined subject entity:

<div itemscope itemtype="http://schema.org/CreativeWork">
    <link itemprop="creator" href="person">
    <!-- Freebase URI for Romeo and Juliet -->
    <link itemprop="sameAs" href="http://www.freebase.com/m/0yq9mqd">
<div itemid="person" itemscope itemtype="http://schema.org/Person">
    <span itemprop="name">William Shakespeare</name>

Both approaches are cumbersome and make authoring data markup in Microdata more complex than necessary, in particular when authoritative URIs for entities from Freebase or Wikidata are the intended subject of a statement. It is unnecessary that the subject entities from external sources like Freebase must be locally defined in order to be used as a the subject of a statement.

Proposed Action: New attribute @itemprop-reverse

After a substantial discussion on the W3C public-vocabs mailing list, we propose to extend the Microdata specification by a mechanism for reverse properties in the form of a new attribute @itemprop-reverse. There has been related discussion on the WHATWG mailing list on April 2014, see here and here.

The new attribute @itemprop-reverse will be equivalent to the existing @itemprop, except for the fact that the subject and the object of the statement are swapped.


E.g. @itemreverseprop, @itempropback, @itemvalueof, or @itemisvalueof:

<div  itemscope itemtype="http://schema.org/Person">
    <span itemprop="name">William Shakespeare</span>
    <link itemprop-reverse="creator" href="http://www.freebase.com/m/0yq9mqd">

The line

<link itemprop-reverse="creator" href="http://www.freebase.com/m/0yq9mqd">

expresses that http://www.freebase.com/m/0yq9mqd is the schema:creator of the person "William Shakespeare".

Alternative approaches, like other attribute names (e.g. @itemreverseprop, @itempropback, @itemvalueof, or @itemisvalueof), a prefix mechanism, or a new attribute that modifies the direction of an @itemprop attribute have been discussed, but were considered inferior. The current approach does not create wrong data with older Microdata consumers.

Examples and Use Cases

There are many relevant usages of a reverse property mechanism. One prominent application is using Freebase entities in markup, which will be very useful for helping search engines to recognize named entities. The current need to locally redefine a Freebase entity in your page just to be able to use it as the subject of a statement is cumbersome.

Linking from a locally defined person to an externally defined piece of creative work

If there is a large number of contributors to a piece of creative work (e.g. a huge choir) or an event, it may happen that we have information about the individual on many pages and want to link to the subject entity.

<div itemscope itemtype="http://schema.org/Person">
    <span itemprop="name">Peter Miller</name>
    <link itemprop-reverse="creator" href="http://www.freebase.com/m/0yq9mqd">

Linking from a company to its externally defined products

schema:manufacturer is defined from a product to a person or organization, but it can also be useful the other way round (e.g. for linking from a business entity page to car models in Freebase, Wikidata or DBPedia.

<div itemscope itemtype="http://schema.org/Company">
    <span itemprop="name">Volkswagen</name>
    <link itemprop-reverse="manufacturer" href="http://www.freebase.com/m/0274dp">

Linking from a brand to an externally defined company

schema:brand is defined from an organization, a person or a product to a brand, but it can also be useful the other way round (e.g. for linking from a brand entity to the company in Freebase, Wikidata or DBPedia.

For instance, Microsoft is the owner of the former Nokia "Lumia" brand:

<div itemscope itemtype="http://schema.org/Brand">
    <span itemprop="name">Lumia</name>
    <link itemprop-reverse="brand" href="http://www.freebase.com/m/04sv4">

Linking from an offer to an externally defined company

Often, it is valuable to specify the company that makes an http://schema.org/Offer. In the original GoodRelations model, this was even a required component. If the company already has an externally defined identifier, it would be handy to reuse that.

<div itemscope itemtype="http://schema.org/Offer">
    <span itemprop="name">Book offer blabla</name>
	<!-- other offer properties here -->
	<!-- the offer is made by Amazon -->
    <link itemprop-reverse="makesOffer" href="http://www.freebase.com/m/0mgkg">

Providing opening hours information for an externally defined place of interest

There are Web sites that provide opening hours information for museums or stores. If the place has an external identifier, it would be handy to be able to link back from the opening hours information to the entity.

Example: The Eiffel tower has the Freebase identifier http://www.freebase.com/m/02j81. Imagine a user-driven site with opening hours information:

<div itemscope itemtype="http://schema.org/OpeningHoursSpecification">
	 <link itemprop-reverse="openingHoursSpecification" href="http://www.freebase.com/m/02j81" />
Opening hours: Mo-Fri,
     <link itemprop="dayOfWeek" 
           href="http://purl.org/goodrelations/v1#Monday" />
     <link itemprop="dayOfWeek" 
           href="http://purl.org/goodrelations/v1#Tuesday" />
     <link itemprop="dayOfWeek" 
           href="http://purl.org/goodrelations/v1#Wednesday" />
     <link itemprop="dayOfWeek" 
           href="http://purl.org/goodrelations/v1#Thursday" />
     <link itemprop="dayOfWeek" 
           href="http://purl.org/goodrelations/v1#Friday" />
     <meta itemprop="opens" content="08:00:00">8:00 a.m. -
     <meta itemprop="closes" content="20:00:00">8:00 p.m.

Linking from a thumbnail to a full-scale image

You can link from an ImageObject to a thumbnail (another ImageObject), but not vice versa.

<div itemscope itemtype="http://schema.org/ImageObject">
  <a itemprop-reverse="thumbnail" href="full/mexico-beach.jpg"
      <img src="thumbnails/mexico-beach.jpg"/>
  <link itemprop="contentURL" href="thumbnails/mexico-beach.jpg"  />

Linking from member pages to an externally defined association, sports team entity, or other group

http://schema.org/Organization defines the member (= has member) property, but we may want to express an "is member of" relationship from a single person.

Example: I am a member of the ACM

<div itemscope itemtype="http://schema.org/Person">
    <span itemprop="name">Martin Hepp</name>
	<!-- Freebase entity for the Association for Computing Machinery -->
    <link itemprop-reverse="member" href="http://www.freebase.com/m/0126n">

Linking from a shopping mall to the businesses contained

http://schema.org/Place provides a containedIn property, but this makes it a bit complicated to model the contained businesses as child elements of the mall. With the new attribute, this variant is possible:

<div itemscope itemtype="http://schema.org/ShoppingCenter">
	<span itemprop="name">The ACME Shopping Mall on Structured Data Avenue</span>
	<span itemprop="description">The ACME Shopping Mall is your one-stop paradise for all data-related shopping needs, from schemas to instance data</span>
	<p>Here is a list of shops inside:</p>
	<div itemprop-reverse="containedIn" itemscope itemtype="http://schema.org/Restaurant">
		<span itemprop="name">Dan Brickley's Data Restaurant</span>
	<div itemprop-reverse="containedIn" itemscope itemtype="http://schema.org/Bakery">
		<span itemprop="name">Ramanathan Guha's Meta Content Framework Bakery</span>

This is also a nice example of using @itemprop-reverse without a <link> element to an external URI.

Of course, one could also use @itemref in this setting, but it will be more complex to understand for humans:

<div id="mall" itemprop="containedIn" itemscope itemtype="http://schema.org/ShoppingCenter">
	<span itemprop="name">The ACME Shopping Mall on Structured Data Avenue</span>
	<span itemprop="description">The ACME Shopping Mall is your one-stop paradise for all data-related shopping needs, from schemas to instance data</span>
	<p>Here is a list of shops inside:</p>
	<div itemscope itemtype="http://schema.org/Restaurant" itemref="mall">
		<span itemprop="name">Dan Brickley's Data Restaurant</span>
	<div itemscope itemtype="http://schema.org/Bakery" itemref="mall">
		<span itemprop="name">Ramanathan Guha's Meta Content Framework Bakery</span>

So the new attribute would also be useful for this case.

Backward and forward links

http://schema.org/Organization provides a member property referencing a http://schema.org/Person and http://schema.org/Person has a memberOf property defined as the inverseOf member. Using both @itemprop and @itemprop-reverse on the same element allows both forward and backward links to be created without introducing global identifiers:

<div itemscope itemtype="http://schema.org/Organization">
   <span itemprop="name">Cryptography Users</span>
   <div itemprop-reverse="memberOf" itemprop="member" itemscope
     <div itemprop-reverse="memberOf" itemprop="member" itemscope
       <span itemprop="name">Alice</span>
     <span itemprop="startDate">1977</span>

This allows a true directed graph representation with an Organization referencing a Person through a Role, which also references the Organization through the same Role, resulting in the following Turtle representation:

@prefix schema: <http://schema.org/> .
@prefix md: <http://www.w3.org/ns/md#> .

_:org a schema:Organization;
   schema:name "Cryptography Users";
   schema:member _:role .
_:role a schema:OrganizationRole;
   schema:startDate "1977";
   schema:member _:person;
   schema:memberOf _:org .
_:person a schema:Person;
   schema:name "Alice";
   schema:memberOf _:role .