-- Cleanup SPARQL DROP QUAD MAP ; SPARQL CLEAR GRAPH ; SPARQL CLEAR GRAPH ; -- Load Mapping Descriptions into a Designated Named Graph (or Internal Virtuoso Document) identified by its IRI SPARQL prefix rr: prefix School: prefix school-stat: prefix rdf: prefix void: prefix scovo: prefix aowl: PREFIX foaf: INSERT { GRAPH { <#TriplesMapCourse> a rr:TriplesMap; rr:logicalTable [ rr:sqlQuery """ SELECT "CourseID", "Title", "Credits", "DepartmentID", "CourseID" FROM "School"."DBA"."Course" """ ]; rr:subjectMap [ rr:termType rr:IRI ; rr:template "http://opllinux5.usnet.private:8708/School/course/CourseID={CourseID}#this"; rr:class School:Course; rr:graph ]; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:courseid ] ; rr:objectMap [ rr:column "CourseID" ]; ] ; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:title ] ; rr:objectMap [ rr:column "Title" ]; ] ; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:credits ] ; rr:objectMap [ rr:column "Credits" ]; ] ; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:course_has_department ] ; rr:objectMap [ rr:termType rr:IRI ; rr:template "http://opllinux5.usnet.private:8708/School/department/DepartmentID={DepartmentID}#this" ]; ] ; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:course_of_coursegrade ] ; rr:objectMap [ rr:parentTriplesMap <#TriplesMapCourseGrade>; rr:joinCondition [ rr:child "CourseID" ; rr:parent "CourseID" ] ; ]; ] ; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:course_of_courseinstructor ] ; rr:objectMap [ rr:parentTriplesMap <#TriplesMapCourseInstructor>; rr:joinCondition [ rr:child "CourseID" ; rr:parent "CourseID" ] ; ]; ] ; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:course_of_onlinecourse ] ; rr:objectMap [ rr:parentTriplesMap <#TriplesMapOnlineCourse>; rr:joinCondition [ rr:child "CourseID" ; rr:parent "CourseID" ] ; ]; ] ; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:course_of_onsitecourse ] ; rr:objectMap [ rr:parentTriplesMap <#TriplesMapOnsiteCourse>; rr:joinCondition [ rr:child "CourseID" ; rr:parent "CourseID" ] ; ]; ] . <#TriplesMapCourseGrade> a rr:TriplesMap; rr:logicalTable [ rr:sqlQuery """ SELECT "EnrollmentID", "Grade", "CourseID", "StudentID" FROM "School"."DBA"."CourseGrade" """ ]; rr:subjectMap [ rr:termType rr:IRI ; rr:template "http://opllinux5.usnet.private:8708/School/coursegrade/EnrollmentID={EnrollmentID}#this"; rr:class School:CourseGrade; rr:graph ]; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:enrollmentid ] ; rr:objectMap [ rr:column "EnrollmentID" ]; ] ; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:grade ] ; rr:objectMap [ rr:column "Grade" ]; ] ; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:coursegrade_has_course ] ; rr:objectMap [ rr:termType rr:IRI ; rr:template "http://opllinux5.usnet.private:8708/School/course/CourseID={CourseID}#this" ]; ] ; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:coursegrade_has_person ] ; rr:objectMap [ rr:termType rr:IRI ; rr:template "http://opllinux5.usnet.private:8708/School/person/StudentID={StudentID}#this" ]; ] . <#TriplesMapCourseInstructor> a rr:TriplesMap; rr:logicalTable [ rr:sqlQuery """ SELECT "CourseID", "PersonID" FROM "School"."DBA"."CourseInstructor" """ ]; rr:subjectMap [ rr:termType rr:IRI ; rr:template "http://opllinux5.usnet.private:8708/School/courseinstructor/CourseID={CourseID}/PersonID={PersonID}#this"; rr:class School:CourseInstructor ; rr:graph ]; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:courseinstructor_has_course ] ; rr:objectMap [ rr:termType rr:IRI ; rr:template "http://opllinux5.usnet.private:8708/School/course/CourseID={CourseID}#this" ]; ] ; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:courseinstructor_has_person ] ; rr:objectMap [ rr:termType rr:IRI ; rr:template "http://opllinux5.usnet.private:8708/School/person/PersonID={PersonID}#this" ]; ] . <#TriplesMapDepartment> a rr:TriplesMap; rr:logicalTable [ rr:sqlQuery """ SELECT "DepartmentID", "Name", "Budget", "StartDate", "Administrator" FROM "School"."DBA"."Department" """ ]; rr:subjectMap [ rr:termType rr:IRI ; rr:template "http://opllinux5.usnet.private:8708/School/department/DepartmentID={DepartmentID}#this"; rr:class School:Department; rr:graph ]; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:departmentid ] ; rr:objectMap [ rr:column "DepartmentID" ]; ] ; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:name ] ; rr:objectMap [ rr:column "Name" ]; ] ; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:budget ] ; rr:objectMap [ rr:column "Budget" ]; ] ; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:startdate ] ; rr:objectMap [ rr:column "StartDate" ]; ] ; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:administrator ] ; rr:objectMap [ rr:column "Administrator" ]; ] ; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:department_of_course ] ; rr:objectMap [ rr:parentTriplesMap <#TriplesMapCourse>; rr:joinCondition [ rr:child "DepartmentID" ; rr:parent "DepartmentID" ] ; ]; ] . <#TriplesMapOfficeAssignment> a rr:TriplesMap; rr:logicalTable [ rr:sqlQuery """ SELECT "InstructorID", "Location", "Timestamp" FROM "School"."DBA"."OfficeAssignment" """ ]; rr:subjectMap [ rr:termType rr:IRI ; rr:template "http://opllinux5.usnet.private:8708/School/officeassignment/InstructorID={InstructorID}#this"; rr:class School:OfficeAssignment; rr:graph ]; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:location ] ; rr:objectMap [ rr:column "Location" ]; ] ; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:timestamp ] ; rr:objectMap [ rr:column "Timestamp" ]; ] ; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:officeassignment_has_person ] ; rr:objectMap [ rr:termType rr:IRI ; rr:template "http://opllinux5.usnet.private:8708/School/person/InstructorID={InstructorID}#this" ]; ] . <#TriplesMapOnlineCourse> a rr:TriplesMap; rr:logicalTable [ rr:sqlQuery """ SELECT "CourseID", "URL" FROM "School"."DBA"."OnlineCourse" """ ]; rr:subjectMap [ rr:termType rr:IRI ; rr:template "http://opllinux5.usnet.private:8708/School/onlinecourse/CourseID={CourseID}#this"; rr:class School:OnlineCourse; rr:graph ]; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:url ] ; rr:objectMap [ rr:column "URL" ]; ] ; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:onlinecourse_has_course ] ; rr:objectMap [ rr:termType rr:IRI ; rr:template "http://opllinux5.usnet.private:8708/School/course/CourseID={CourseID}#this" ]; ] . <#TriplesMapOnsiteCourse> a rr:TriplesMap; rr:logicalTable [ rr:sqlQuery """ SELECT "CourseID", "Location", "Days", "Time" FROM "School"."DBA"."OnsiteCourse" """ ]; rr:subjectMap [ rr:termType rr:IRI ; rr:template "http://opllinux5.usnet.private:8708/School/onsitecourse/CourseID={CourseID}#this"; rr:class School:OnsiteCourse; rr:graph ]; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:location ] ; rr:objectMap [ rr:column "Location" ]; ] ; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:days ] ; rr:objectMap [ rr:column "Days" ]; ] ; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:time ] ; rr:objectMap [ rr:column "Time" ]; ] ; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:onsitecourse_has_course ] ; rr:objectMap [ rr:termType rr:IRI ; rr:template "http://opllinux5.usnet.private:8708/School/course/CourseID={CourseID}#this" ]; ] . <#TriplesMapPerson> a rr:TriplesMap; rr:logicalTable [ rr:sqlQuery """ SELECT "PersonID", "LastName", "FirstName", CONCAT(CONCAT("FirstName",' ') , "LastName") AS "Name", "HireDate", "EnrollmentDate" FROM "School"."DBA"."Person" """ ]; rr:subjectMap [ rr:termType rr:IRI ; rr:template "http://opllinux5.usnet.private:8708/School/person/PersonID={PersonID}#this"; rr:class School:Person, foaf:Agent, foaf:Person; rr:graph ]; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:personid ] ; rr:objectMap [ rr:column "PersonID" ]; ] ; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:lastname ] ; rr:objectMap [ rr:column "LastName" ]; ] ; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:firstname ] ; rr:objectMap [ rr:column "FirstName" ]; ] ; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:name ] ; rr:objectMap [ rr:column "Name" ]; ] ; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:hiredate ] ; rr:objectMap [ rr:column "HireDate" ]; ] ; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:enrollmentdate ] ; rr:objectMap [ rr:column "EnrollmentDate" ]; ] ; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:person_of_coursegrade ] ; rr:objectMap [ rr:parentTriplesMap <#TriplesMapCourseGrade>; rr:joinCondition [ rr:child "PersonID" ; rr:parent "StudentID" ] ; ]; ] ; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:person_of_courseinstructor ] ; rr:objectMap [ rr:parentTriplesMap <#TriplesMapCourseInstructor>; rr:joinCondition [ rr:child "PersonID" ; rr:parent "PersonID" ] ; ]; ] ; rr:predicateObjectMap [ rr:predicateMap [ rr:constant School:person_of_officeassignment ] ; rr:objectMap [ rr:parentTriplesMap <#TriplesMapOfficeAssignment>; rr:joinCondition [ rr:child "PersonID" ; rr:parent "InstructorID" ] ; ]; ] . } } ; -- Next command is commented out due to fact that it produces urn: unsupported error -- DB.DBA.R2RML_GENERATE_LINKED_VIEW('urn:School:8708:r2rml', 'http://opllinux5.usnet.private:8708/School#', 0); -- DB.DBA.R2RML_GENERATE_LINKED_VIEW('urn:School:8708:r2rml', 'http://opllinux5.usnet.private:8708/School#', 0); -- THIS WORKS for generating triples for Virtual RDF Views Graph: DB.DBA.R2RML_GENERATE_LINKED_VIEW('http://kingsley.idehen.net/DAV/home/kidehen/Public/R2RML%20Demos/School-8708-r2rml.ttl', --'http://opllinux5.usnet.private:8708/School#', 0); -- THIS WORKS for generating triples for both Virtual & Physical RDF Views Graph: DB.DBA.R2RML_GENERATE_LINKED_VIEW('http://kingsley.idehen.net/DAV/home/kidehen/Public/R2RML%20Demos/School-8708-r2rml.ttl', -- 'urn:opllinux5.usnet.private:8708:School', 1); -- Generate & Execute Virtual RDF Views Script, hence the use of EXEC() EXEC ('SPARQL ' || DB.DBA.R2RML_MAKE_QM_FROM_G ('urn:school:8708:sql:r2rml:mappings')); -- Test RDF generated Virtual RDF Views SPARQL SELECT SAMPLE(?s) AS ?sample COUNT(1) AS ?count ?o FROM WHERE {?s a ?o} GROUP BY ?o ORDER BY DESC(?count) LIMIT 50 ; -- Test 2 (workaround for RDF Views using rr:query) SPARQL SELECT ?o IRI(max(str(?s))) AS ?sample COUNT(1) AS ?count FROM WHERE {?s a ?o} GROUP BY ?o ORDER BY DESC(?count) LIMIT 50 ; -- Sync Triples from Virtual RDF Views Graph to Physical RDF Views Graph RDF_VIEW_SYNC_TO_PHYSICAL ('http://opllinux5.usnet.private:8708/School#', 1, 'urn:opllinux5.usnet.private:8708:School'); -- Test Phyical RDF Views sync'd from Virtual RDF Views Graph SPARQL SELECT count(*) FROM WHERE {?s ?p ?o} ; SPARQL SELECT count(*) FROM WHERE {?s ?p ?o} ; SPARQL SELECT SAMPLE(?s) AS ?sample COUNT(1) AS ?count ?o FROM WHERE {?s a ?o} GROUP BY ?o ORDER BY DESC(?count) LIMIT 50 ;