Resource Description Framework (RDF) is an open standard of the W3C to describe digital resources with semantic meaning. Data described in RDF format can be exchanged and reused while maintaining a 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 first article describes how concepts with associated attributes are defined with RDF-Schema.
The RDF Standard describes digital resources by defining and using classes and properties. RDF-Schema (RDFS) is one example of several languages that offer notation rules for describing resources with a semantic meaning by creating vocabulary and taxonomies of related concepts. Common to all languages following the RDF standard are the way they describe resources in the form of a statement that consist of subject, predicate, object, which constitute a triplet. All resources in RDF are identified by IRI (international resource identifier) which is a generalization of URI. This enables resources / triplets to be linked globally since IRI / URI is a fundamental part of the HTTP protocol for identifying web resources. There are other languages that enable more advanced classification systems in the form of ontology that can describe rules, temporal and dynamic relationship among resources, such as OWL 2 (Web Ontology Language).
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 humans and used through this article series unless otherwise stated. Other formats in the Turtle family are more compact and optimized formats for machine reading, 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 name and creatorOf are objects in the statement of Picasso, where name is a text string and creators a object which is a subject in another statement. This could an objekt in the same model or if we want to use the definition of the painting Guernica from 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 short and easy 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 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 exadeducmple, 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 the predicate rdfs: range is used. For example, we can define that the value of P belongs to the instance of 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 relations between resources. Deriving implicit connections between resources enables logical reasoning and is a powerful feature of the RDF framework. The next RDF elementary guide presents a semantic data model that describes classes and properties of artists and paintings, and interlink resources from Wikidata that also uses the RDF standard to describe resources.