3

Supposing we have the following triple in Turtle syntax:

<http:/example.com/Paul> <http:/example.com/running> <http:/example.com/10miles> .

How do I add a start and end time? For example if I want to say he started at 10 am and finished his 10miles run at 12 am. I want to use xsd:dateTime.

unor
  • 92,415
  • 26
  • 211
  • 360
user3352632
  • 617
  • 6
  • 18
  • given that RDF only supports binary relations, either 1) an n-ary relation via some intermediate node (might be a blank node) or 2) reification – UninformedUser Apr 09 '18 at 08:01
  • 3
    The answers here mention reification but I'm not sure if the intent is to add timestamps to the triple or to the event of Paul running. If the intent is to represent Paul's runs, then you'd have a Run class, and Paul would be related to multiple individuals of type Run; timestamps would then be triples having these individuals as subjects. If the triple itself should be the subject, then reification is probably what's desired. – Ignazio Apr 09 '18 at 12:10
  • Is this a specific run/event named "10miles"? Or is it *a* run that’s 10 miles long? – unor Apr 09 '18 at 14:43
  • @unor it is a run that is 10 miles long. one run of paul's hundrets of runs. he is an amazing runner and runs every day. – user3352632 Apr 09 '18 at 16:39
  • @Ignazio can you please elaborate your answer with an extra run class. Thanks a lot in advance – user3352632 Apr 09 '18 at 16:44
  • It's the same concept that @AKSW has mentioned, n-ary relationship. An individual replaces the object of your original triple, and any extra information you need to describe the run is attached to this individual, which represents one of Paul's many runs. Paul would then have a triple for each run, linking him to multiple individuals, each individual with timestamps. – Ignazio Apr 09 '18 at 17:12
  • Possible duplicate of [How can I express additional information (time, probability) about a relation in RDF?](https://stackoverflow.com/questions/32923213/how-can-i-express-additional-information-time-probability-about-a-relation-in) – Jeen Broekstra Apr 10 '18 at 06:57

3 Answers3

4

One way of doing this is through reification - making statements about the statement. Here, you have a choice of giving the statement a URI, so that it's externally dereferenceable, or using a blank node. That would mean, in your case, that you need to identify the statement by making statements about it subject, object and predicate, and tell more things about it, in your case - about start and end of a period it represents. This is how it would look with a blank node:

[
  rdf:type rdf:Statement ;   #this anonymous resource is a Statement... 
  rdf:subject ex:Paul ;      #...with subject Paul
  rdf:predicate ex:running ; #...predicate running
  rdf:object "10miles" ;     #...and object "10miles"
  ex:hasPeriodStart "2018-04-09T10:00:00"^^xsd:dateTime ;
  ex:hasPeriodEnd "2018-04-09T12:00:00"^^xsd:dateTime ;
].

When defining ex:hasPeriodStart and ex:hasPeriodEnd you might want to declare their type and range:

ex:hasPeriodStart
  rdf:type owl:DatatypeProperty ;
  rdfs:range xsd:dateTime ;

Or you might prefer to assure the quality of your data with SHACL, where you'll define your constraints with shape expressions.

I'd recommend not to define your time-related properties but to reuse those from the time ontology.

Ivo Velitchkov
  • 2,361
  • 11
  • 21
1

Give each of Paul’s runs its own URI:

@prefix ex: <http://example.com/> .

ex:Paul ex:running ex:PaulsRun1, ex:PaulsRun2, ex:PaulsRun3 .

This allows you (and others) to make statements about each run:

@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

ex:PaulsRun3 
  ex:lengthInMiles 10.0 ;
  ex:startTime "2018-04-09T10:00:00"^^xsd:dateTime ;
  ex:endTime "2018-04-09T12:00:00"^^xsd:dateTime .

Instead of listing all these runs as objects of ex:Paul ex:running, you could specify the runner for each run:

@prefix ex: <http://example.com/> .

ex:PaulsRun1
  ex:runner ex:Paul .
  # ex:lengthInMiles, ex:startTime, ex:endTime, etc.

ex:PaulsRun2
  ex:runner ex:Paul .
  # ex:lengthInMiles, ex:startTime, ex:endTime, etc.

ex:PaulsRun3 
  ex:runner ex:Paul .
  # ex:lengthInMiles, ex:startTime, ex:endTime, etc.

If you don’t want to create a URI for each runner’s run, you could use (unlabeled) blank nodes instead. But this makes it hard/impossible for others to refer to these runs.

unor
  • 92,415
  • 26
  • 211
  • 360
0

Just as an idea.

1. The modelling part (not much RDF involved)

{
    "runs": [
        {
            "id": "runs:0000001",
            "distance": {
                "length": 10.0,
                "unit": "mile"
            },
            "time": {
                "start": "2018-04-09T10:00:00",
                "end": "2018-04-09T12:00:00"
            },
            "runner": {
                "id": "runner:0000002",
                "name": "Paul"
            }
        }
    ]
}

2. The RDF part: define a proper context for your document.

   "@context": {
        "ical": "http://www.w3.org/2002/12/cal/ical#",
        "xsd": "http://www.w3.org/2001/XMLSchema#",
        "runs": {
            "@id": "info:stack/49726990/runs/",
            "@container": "@list"
        },
        "distance": {
            "@id": "info:stack/49726990/distance"
        },
        "length": {
            "@id": "info:stack/49726990/length",
            "@type": "xsd:double"
        },
        "unit": {
            "@id": "info:stack/49726990/unit"
        },
        "runner": {
            "@id": "info:stack/49726990/runner/"
        },
        "name": {
            "@id": "info:stack/49726990/name"
        },
        "time": {
            "@id": "info:stack/49726990/time"
        },
        "start": {
            "@id":"ical:dtstart",
            "@type": "xsd:dateTime"
        },
        "end": {
            "@id":"ical:dtend",
            "@type": "xsd:dateTime"
        },
        "id": "@id"
    }

3. The fun part: Throw it to an RDF converter of your choice

This is how it looks in JSON-Playground

jschnasse
  • 8,526
  • 6
  • 32
  • 72