Tutorial on RDF Data Modelling
Domain Description 1
A student has a name and enrols in a program and attends courses that are part of a program. A
course can have overlap with other courses in other programs. A course has a title and taught by a
teacher. A course has logistics which is described by location and schedule. Location is a classroom
which is identified by a label. A course is conducted on more than one day and a day’s schedule is
defined with day, start time, duration. A course is taught by a single teacher. A teacher is associated
with a department which has got a name. A teacher may visit different conferences in a year. A
conference is characterized by year and name. A teacher has several research interests and has a
citation count on the paper published.
Represent the knowledge through graph based data model.
Year
Citation Paper Title prop:year
Count
rdfs:label
Name
prop:title
prop:citation
prop:conferenceVisited Department
prop:paperPublished Name
Research schema:Faculty
prop:researchArea
Area
Classroom
prop:taughtBy
prop:logistics
Day
schema:Course prop:day
prop: hasOverlapWith prop:schedule
prop:partOf prop:duration Duration
prop:title
prop:attendedBy
rdf:_1 prop:startTime
Title Start Time
schema:Student rdf:_n
rdf:type
prop:name
prop:enrolledIn
rdf:Seq
schema:Program Name
The namespaces used in the data model are:
PREFIX prop: <[Link]
PREFIX data: <[Link]
PREFIX schema: <[Link]
PREFIX rdf: <[Link]
Answer the following queries based on graph data model
Q1: Find the schedule of all the courses
PREFIX prop: <[Link]
PREFIX data: <[Link]
PREFIX schema: <[Link]
PREFIX rdf: <[Link]
SELECT ?course ?classroom ?day ?dur ?start
WHERE
{
?course prop:logistics ?logistics .
?logistics prop:classroom ?classroom .
?logistics prop:schedule/(rdf:_1|rdf:_2|rdf:_3|rdf:_4)*
?singleSchedule .
?singleSchedule prop:day ?day .
?singleSchedule prop:duration ?dur .
?singleSchedule prop:startTime ?start .
}
Q2: Find the faculty with maximum no of citation count
PREFIX prop: <[Link]
PREFIX data: <[Link]
PREFIX schema: <[Link]
PREFIX rdf: <[Link]
SELECT ?faculty_name (SUM(?citation) AS ?citemax)
WHERE
{
?faculty rdf:type schema:Faculty .
?faculty prop:name ?faculty_name .
?faculty prop:paperPublished [prop:citation ?citation].
}
GROUP BY ?faculty_name
ORDER BY DESC(?citemax)
LIMIT 1
Q3: Find the courses that have overlaps with a common course
PREFIX prop: <[Link]
PREFIX data: <[Link]
PREFIX schema: <[Link]
PREFIX rdf: <[Link]
SELECT ?course_name ?overlapCourseName
WHERE
{
?course prop:hasOverlapWith/^prop:hasOverlapWith
?overlappedCourse .
FILTER (?course !=?overlappedCourse)
?course prop:title ?course_name .
?overlappedCourse prop:title ?overlapCourseName .
}
Domain Description 2
We describe the sales data with attributes as company, amount and year.
Amount Year
sales:Company
sales-schema:amount
sales-schema:year
sales-schema:company
sales-schema:Sales
Q1: What is the total sale of a company in 2009 .
PREFIX sales: <[Link]
PREFIX sales-schema: <[Link]
PREFIX rdf: <[Link]
SELECT ?company ((SUM(?amt)) AS ?total09)
WHERE
{
?data rdf:type sales-schema:Sale ;
sales-schema:company ?company ;
sales-schema:amount ?amt ;
sales-schema:year 2009 .
}
GROUP BY ?company
Q2: Which companies have increased their sales from 2009 to 2010?
PREFIX sales: <[Link]
PREFIX sales-schema: <[Link]
PREFIX rdf: <[Link]
SELECT ?company ?total09 ?total10
WHERE
{
{
SELECT ?company ((SUM(?amt)) AS ?total09)
WHERE
{
?data rdf:type sales-schema:Sale ;
sales-schema:company ?company ;
sales-schema:amount ?amt ;
sales-schema:year 2009 .
}
GROUP BY ?company
}
{
SELECT ?company (SUM(?amt) AS ?total10)
WHERE
{
?data rdf:type sales-schema:Sale ;
sales-schema:company ?company ;
sales-schema:amount ?amt ;
sales-schema:year 2010 .
}
GROUP BY ?company
}
FILTER (?total10>?total09)
}