Reputation: 121
I'm learning about the semantic web and I'm trying to wrap my head around the idea of triples. As far as I understand it, RDF is a method of modelling data. It's a representation of how data is structured or connected to each other over the web.
RDF uses triples to represent the data structure, in the order of subject-predicate-object. Each actual data item is taken from it's URI. The URI matches data across different servers. A shortcut for URI in modelling RDF is using the Turtle Format, which is qnames (<namespaces>: <identifier>
) + triples.
With this in mind, we have the statement:
David Lectures The Algorithms Course in 2017-18.
First question, where would this statement come from, or what is a statement in the context of a semantic web?
Second question, how would you model this in RDF? The way I see it, we would first determine the triple.
The subject is David.
The predicate is Lectures.
The object is Algorithms.
What's the 2017-18?
Upvotes: 1
Views: 381
Reputation: 2431
An RDF statement is a record of utterance, made following the form, specified by the RDF standard, where at least the subject and the predicate are URI. Read more about RDF statements here. For the statement "David lectures The Algorithms Course in 2017-18", you would need identifiers for "David", "lecture" and the "Algorithms Course". You may identify for an exercise David as ex:David
but for real implementation, this should be avoided as "David" is just one of many properties describing the resource. Also, mnemonic URIs, while easier for people to work with, are not desirable when aiming persistence of the URIs. For example, having an URI to identify an organisation, using the acronym of the organisation in English, should be avoided as the acronym may change while other statements remain valid. Having this in mind, let's say we have ex:s1
, ex:p11
, and ex:o1
to identify the first three parts of the statement. Then we have to make a few RDF statements to make the desired one formally and following a good practice.
ex:s1
ex:p11 ex:o1 ;
foaf:firstName "David" ;
ex:o1 rdfs:label "The Algorithms Course" .
ex:p1 rdfs:label "lectures" .
With this, we have said that David lectures this particular thing. The property ex:p11
would often come from an ontology, where there will be more statements about it, for example, that it is an object property, that it is a certain type of activity and so on. As machines wouldn't know what kind of thing is ex:o1
, it would also need as a class course, and a type of a course or an individual (often referred to as "instance" but wrongly in my opinion) of that type.
Then for this particular course, we need to say that:
ex:o1
ex:hasPeriodEnd "2018"^^xsd:gYear ;
ex:hasPeriodStart "2017"^^xsd:gYear .
Alternatively, we can reify the statement ex:s1 ex:p11 ex:o1
(in other words to make another statement about this statement):
[
rdf:type rdf:Statement ;
ex:hasPeriodEnd "2018"^^xsd:gYear ;
ex:hasPeriodStart "2017"^^xsd:gYear ;
rdf:object ex:o1 ;
rdf:predicate ex:p11 ;
rdf:subject ex:s1 ;
].
There are other ways to make this second statement, depending on the intention and context. For example:
ex:o1
a ex:course1;
ex:hasPeriodEnd "2018"^^xsd:gYear ;
ex:hasPeriodStart "2017"^^xsd:gYear .
ex:course1
rdfs:subClassOf ex:course;
rdfs:label "The Algorithms Course".
ex:course rdfs:label "Course".
And here's the specification of the prefixes used:
@prefix ex: <http://example.org/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>
Upvotes: 1
Reputation: 5485
First question, where would this statement come from[?]
The particular statement you mention could be from the syllabus of a university. Does it really matter? When you are teaching yourself relational databases, you do not ask yourself where the data comes from, do you?
or what is a statement in the context of a semantic web?
If by this you mean "what is an RDF statement", then the answer is given in Section 1.2 of RDF 1.1 Concepts and Abstract Syntax. Precisely, it says:
Asserting an RDF triple says that some relationship, indicated by the predicate, holds between the resources denoted by the subject and object. This statement corresponding to an RDF triple is known as an RDF statement.
So the RDF triple is what can be written and read, or transmitted over the wires, and the RDF statement is what the triple expresses, or what it means.
Second question, how would you model this in RDF? The way I see it, we would first determine the triple.
As in modelling relational schemas, or UML, or any modelling language, there are multiple ways of representing the same knowledge. Ivo Velitchkov is giving a viable option.
As far as I'm concerned, I would not advise using RDF reification (that is, the technique consisting in using rdf:Statement
, rdf:subject
, rdf:predicate
, and rdf:object
as in Ivo's answer). Instead, I would model courses as things that happen over a period of time, which would make The Algorithms Course in 2017-18 a different course from The Algorithms Course in 2016-17. The Algorithms Course as a whole would be a course series.
Also, what "David lectures The Algorithms Course" means is not totally clear. Does it mean that he gives some lecture in this course, or does it mean he gives all the lectures in this course? Is he the professor responsible for the course, while several lecturers may teach it as well?
You may use the following model:
:algo a c:CourseSeries;
rdfs:label "The Algorithms Course"@en;
p:hasEdition
:algo-2016-2017,
:algo-2017-2018 .
:algo-2017-2018 a c:Course;
rdfs:label "The Algorithms Course, 2017 edition"@en;
p:responsible :David;
p:startingDate "2017-11-23"^^xsd:date;
p:endingDate "2018-02-10"^xsd:date;
p:hasSession
:algo-2017-2018-s1,
:algo-2017-2018-s2,
:algo-2017-2018-s3,
:algo-2017-2018-s4,
:algo-2017-2018-s5 .
:algo-2017-2018-s1 a c:Lecture;
rdfs:label "Sorting algorithms"@en;
p:taughtBy :David;
p:location :room42;
p:starts "2017-11-23T08:30:00Z"^xsd:dateTime;
p:starts "2017-11-23T11:30:00Z"^xsd:dateTime .
:algo-2017-2018-s1 a c:Lecture;
rdfs:label "Search algorithms"@en;
p:taughtBy :Tom;
p:location :room123;
p:starts "2017-12-07T08:30:00Z"^xsd:dateTime;
p:starts "2017-12-07T11:30:00Z"^xsd:dateTime .
... # etc.
Upvotes: 1