The Resource Description Framework (RDF) is an open standard from W3C to describing digital resources with semantic meaning. Data described in RDF format can be exchanged and reused with retained conceptual understanding of resources between businesses, industries and countries. This is the first article in a series of guides to get started describing data with semantic meaning. The reader is recommended to read W3C guide RDF 1.1 Primer to take advantage of the article series, and gives a good introduction of what the RDF framework consists of. The first article describes how resources are defined in RDFS. Next article presents a semantic model and explains how resources from Wikidata and other sources can be linked to enrich the description.
Resources are described by creating classes and properties, for example with RDF schema (RDFS). RDFS is one of several languages that offers notation rules for describing resources with semantic meaning to create simpler vocabulary and taxonomies. Common to all languages within RDF is the description of resources in the form of a Statement which consists of subject, predicate and object which is called triplet. All resources in RDF are identified using International Resource Identifier (IRI), which is a generalisation of URI (ASCII) that allows UFT-8 characters (Unicode transformation format). Subsequent guides present other languages to define more advanced classification systems in the form of ontologies that can describe temporal and dynamic conditions for digital resources.
To define a statement in RDF, there are a number of different formats that has different purposes. The Turtle (.ttl) format is a syntax that has abbreviations, prefixes and is easier to read for people and used is used through the article series unless otherwise stated. Other formats in the Turtle family are more compact and optimized formats for machines, such as N-Triples, Q-Quads.
Classes and properties in RDFS
Classes (rdfs: Class) are used to classify resources. An instance of an rdfs: Class is defined using the predicate rdf: type. For example, we can define that Artist is a class and that Picasso is an instance of the Artist class. Note that ex, rdf and rdfs are IRI prefixes and are abbreviations instead of writing the entire path to resources (https://www.clearbyte.org/example/Artist).
ex:Artist rdf:type rdfs:Class . ex:Picasso rdf:type ex:Artist .
Properties (rdfs: Property) is used to add attributes to classes. Similar to how we define classes, we can define instances of properties to add attributes to statements. In the example from earlier we add the properties (predicate) ex: name and ex: created. Name is defined by a text string (literal) “Pablo Picasso” and creator (ex: creatorOf) of an object in the form of an instance of the ex: Guernica class. Note that both names and creators are objects in the staement of Picasso, where name is a text string and creators a object which is a subject in another statement. This could be in the same model or if we want to use the definition of the painting Guernica in Wikidata’s (Wikipedia) by using an IRI prefix for the resource wd: Q175036 (https://www.wikidata.org/wiki/Q175036). Turtle offers the abbreviation of rdf: type in the form of the letter a, which makes the syntax shorter and easier to read.
ex:name a rdfs:Property . ex:creatorOf a rdfs:Property . ex:Picasso a ex:Artist ; ex:name “Pablo Picasso”; ex:creatorOf ex:Guernica.
Predicate interconnect the subject and the object in a statement which forms the basis of a graph. Subjects and objects can be seen as nodes and the predicate as a meaningful link that describes the relationship between the nodes.
Note that the definition of properties usually starts with a lowercase letter and classes with a uppercase.
Domain & Range
To semantically describe and derive relationships between subjects and objects, rdfs: domain and rdfs: range are used. The predicate rdfs: domain declares that a property belongs to one or more classes. For example, we can define that property P belongs to class D.
P rdfs:domain D . ex:hasMother rdfs:domain ex:Person ; ex:frank ex:hasMother ex:frances .
The example implicitly derives that ex: frank also belongs to the ex: Person class because ex: hasMother belongs to the ex: Person class.
To deduce that the value of an instance belongs to one or more classes / properties, the predicate rdfs: range is used. For example, we can define that the value of P belongs to the class R.
P rdfs:range R .
The difference between domain and range is that the first declares that a property belongs to a domain of one or more classes. And that range declares that a property belongs to one or more instances of classes. The following statement illustrates the difference. The example defines two classes, book and person, and the author property. The author property belongs to the domain of Book. But when instantiating a book, the name of the author refers to the class Person.
ex:Book a rdfs:Class . ex:Person a rdfs:Class . ex:author a rdf:Property . ex:author rdfs:domain ex:Book . ex:author rdfs:range ex:Person .
The example below derives that the value of the ex:motherTo property belongs to both the ex: Female and ex: Person class.
ex:motherTo rdfs:range ex:Female . ex:motherTo rdfs:range ex:Person .
The following statement describes that Eva is the mother to Pete and implicitly also a woman and a person.
ex:Eva ex:motherTo ex:Pete .
Definitions of properties using rdfs: range can also be used to describe the data type such as integers, decimal numbers et cetera if it is not a text string which is the default.
ex:age rdf:type rdf:Property . ex:age rdfs:range xsd:integer .
The ability to declare properties belonging to a specific class (domain) or a selection (range) of instances of classes makes it possible to draw conclusions (inference) through implicit The ability to declare properties belonging to a specific class (domain) or a selection (range) of instances of classes makes it possible to draw conclusions (inference) through implicit links between resources. Deriving implicit connections between resources enables logical reasoning and is a powerful feature of the RDF framework. The next RDF elementry guide presents a semantic data model that describes classes and properties of artists and paintings, and links in related descriptions from Wikidata that also describe resources in RDF format.