Question

I want to do a sesame rdf database with workers in a company. The workers are involved in some projects in a date range. They also have computers. So after database, I must be able to search that database according to computers used by some people or people worked in some projects in the past or now. So, I cant decide how to order attributes of the worker, company, project, computer because I dont know where to place the attribute year. For example, workers' past companies or past projects... how can I place year in the rdf file below? I didnt place year in this file in a proper way, I think. Because start and end dates should be defined in some way or a date range? After that how to search with sparql to find people working in a special project now or before now? Or people using same computer in different years?

<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:Worker="http://www.semantic.fake/Worker#"
xmlns:Company="http://www.semantic.fake/Company"
xmlns:Project="http://www.semantic.fake/Project">

<rdf:Description
rdf:about="http://www.semantic.fake/Worker/Worker1">
  <Worker:worker_name>Bill Gates</Worker:worker_name>
  <Worker:company_name>Microsoft</Worker:company_name>
  <Worker:department>Software</Worker:department>
  <Worker:task>Co-Founder</Worker:task>
  <Worker:project_name>Windows9</Worker:project_name>
  <Worker:year>2010</Worker:year>

</rdf:Description>

<rdf:Description
rdf:about="http://www.semantic.fake/Worker/Worker2">
  <Worker:worker_name>Steve Jobs</Worker:worker_name>
  <Worker:company_name>Apple</Worker:company_name>
  <Worker:department>Software</Worker:department>
  <Worker:task>Co-Founder</Worker:task>
  <Worker:project_name>Inertial Navigation</Worker:project_name>
  <Worker:year>2008</Worker:year>
  <Worker:computer>LG2</Worker:computer>
</rdf:Description>

<rdf:Description
rdf:about="http://www.semantic.fake/Worker/Worker3">
  <Worker:worker_name>Ozge Akbulut</Worker:worker_name>
  <Worker:company_name>Pozitron</Worker:company_name>
  <Worker:department>Software</Worker:department>
  <Worker:task>Intern</Worker:task>
  <Worker:project_name>Semantic Web</Worker:project_name>
  <Worker:year>2013</Worker:year>
  <Worker:computer>LG1</Worker:computer>
</rdf:Description>

<rdf:Description
rdf:about="http://www.semantic.fake/Company/Company1">
  <Company:company_name>Pozitron</Company:company_name>
  <Company:location>Ayazağa</Company:location>
</rdf:Description>

<rdf:Description
rdf:about="http://www.semantic.fake/Company/Company2">
  <Company:company_name>Garanti Teknoloji</Company:company_name>
  <Company:location>Güneşli</Company:location>
</rdf:Description>

<rdf:Description
rdf:about="http://www.semantic.fake/Company/Company3">
  <Company:company_name>Microsoft</Company:company_name>
  <Company:location>US</Company:location>
</rdf:Description>

<rdf:Description
rdf:about="http://www.semantic.fake/Company/Company4">
  <Company:company_name>Apple</Company:company_name>
  <Company:location>US</Company:location>
</rdf:Description>

<rdf:Description
rdf:about="http://www.semantic.fake/Project/Project1">
  <Project:project_name>BKM Express</Project:project_name>
  <Project:company_name>Pozitron</Project:company_name>
  <Project:year>2013</Project:year>
</rdf:Description>

<rdf:Description
rdf:about="http://www.semantic.fake/Project/Project2">
  <Project:project_name>Iscep</Project:project_name>
  <Project:company_name>Pozitron</Project:company_name>
  <Project:year>2013</Project:year>
</rdf:Description>

<rdf:Description
rdf:about="http://www.semantic.fake/Project/Project3">
  <Project:project_name>Semantic Web</Project:project_name>
  <Project:company_name>Pozitron</Project:company_name>
  <Project:year>2013</Project:year>
</rdf:Description>

<rdf:Description
rdf:about="http://www.semantic.fake/Project/Project4">
  <Project:project_name>Inertial Navigation</Project:project_name>
  <Project:company_name>Apple</Project:company_name>
  <Project:year>2009</Project:year>
</rdf:Description>

<rdf:Description
rdf:about="http://www.semantic.fake/Project/Project5">
  <Project:project_name>Windows9</Project:project_name>
  <Project:company_name>Microsoft</Project:company_name>
  <Project:year>2011</Project:year>
</rdf:Description>


</rdf:RDF>
Was it helpful?

Solution

You need to step away from the syntax and think about the conceptual model. In your model, you have workers, projects, companies, and departments. I recommend you represent all of these as classes in your RDF model.

ex:Worker a rdfs:Class .
ex:Project a rdfs:Class .
ex:Company a rdfs:Class .
ex:Department a rdf:Class .

(as an aside, I'm using Turtle syntax for RDF instead of RDF/XML, because it is far easier to read and edit, and makes the actual structure of your data far clearer. I really recommend you learn it and use it instead of RDF/XML)

However, you also want to say things about the employment of certain people in certain projects/companies/departments (such as when they started and when they stopped working there). This means that you need to represent that relationship as an object in its own right, so that you can say things about it. For example, to express that a worker ex:worker1 was employed by company ex:apple between two dates, and then later was employed by company ex:microsoft you could do something like this:

ex:worker1 a ex:Worker ;
           ex:name "Steve Jobs"; 
           ex:employment ex:employment1 ; 
           ex:employment ex:employment2 .

ex:employment1 a ex:EmploymentRelation ;
               ex:forCompany ex:apple ;
               ex:startDate "20010101T00:00:00Z"^^xsd:dateTime ;
               ex:endDate "20050101T00:00:00Z"^^xsd:dateTime .

ex:employment2 a ex:EmploymentRelation ;
               ex:forCompany ex:microsoft ;
               ex:startDate "20060101T00:00:00Z"^^xsd:dateTime ;
               ex:endDate "20080101T00:00:00Z"^^xsd:dateTime .

Once you have the data modeled as above, if you wanted to do a SPARQL query asking for all people who worked for apple between two dates, you'd do something like this (as a simple example):

 SELECT ?worker ?name
 WHERE { ?worker a ex:Worker ;
                 ex:name ?name ;
                 ex:employment [ ex:forCompany ex:apple ;
                                 ex:startDate ?start ;
                                 ex:endDate ?end ] .
         FILTER (?start > "20001231T00:00:00Z"^^xsd:dateTime)
         FILTER (?end < "20120101T00:00:00Z"^^xsd:dateTime
 }

(by the way, the above shows again why using Turtle is a good idea: Turtle syntax and the SPARQL query language are very closely matched - once you understand one, the other follows naturally).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top