SPRQL query , query about the hierarchy of instances in the ontology - sparql

If I want to query about the hierarchy of my individual in the ontology (Protege). any idea how to write this query in SPRQL.
for example, person1 in individual in the ontology. how can I show in which class this person is belong?
Thanks

Related

addition of rules and value assigning in an ontology

Say a degree recommendation ontology which is supposed to recommend a degree programme according to certain set of results you get for an exam.
E.g. a students chooses a stream he did the exam in and his results are: for chemistry, physics, and maths are C, C, C. Thereby he is supposed to be recommended a degree from a particular university.
The class hierarchy of the ontology is as
stream
subject
University
Faculty
Department
Degree
Object properties have been defined as well.
Should the universities such as "University A" , "University B" have properties assigned in the class or to the individual?
How would I be able to assign different results to each subject?
How would I be able to add rules and conditions to the ontology?
E.g. engineering stream consists of only 3 subjects that can be done which are chemistry, physics and maths.
E.g. if you get a result of 'F' in one of those subjects a degree wont be recommended.

LIKE query with a varying number of LIKE’s

My current test revolves around a hypothetical database consisting of a PERSON table populated with their details.
I can undertake a simple LIKE query were I return the details of say a person or persons named Tom.
My question is how can I build a query were there may be multiple names and return their details?
I my exercise there is a checkbox list of names and I need to return the details for all those I select?
Thank you in advance for your assistance.

Insert mysql records into OWL ontology as individuals

I created an ontology using Protege and it saves as .OWL file in RDF/XML serialization.
My ontology has two main Classes.. Category and Review.
I have defined the object property called isAbout which connect the category individuals and review individuals.
I have created some named individuals under both classes. Then I load my ontology using java jena and query some data using SPARQL.
So far so good..
I have some review data in a MySQL table which I want to map with my ontology and query those results as well.
My database table with sample record.
------------------------------------
| Review | Rating | Category |
------------------------------------
| "Great one" | 5 | "Display" |
------------------------------------
I want to convert this data into RDF and insert those records as Review individuals into ontology. There will be an category individual which maps with Category value in the database table. So I want to link this newly created individuals using isAbout object property as well.
So how can I do this?
Ps: As a concept I want to integrate distributed data sources into a common platform. Am I on the track or doing something wrong or is there a better way to do this?
---- Update 2018/04/13 ----
I made a progress with D2RQ tool. Which allows me to map the Database tables and columns to ontology and generate RDF. Now the data in my table is represented as follow in a separate RDF.
<rdf:Description rdf:about="reviews/3">
<vocab:reviews_Category>OLED</vocab:reviews_Category>
<vocab:reviews_Rating rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">3</vocab:reviews_Rating>
<vocab:reviews_Review>wow</vocab:reviews_Review>
<vocab:reviews_ID rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">3</vocab:reviews_ID>
<rdfs:label>reviews #3</rdfs:label>
<rdf:type rdf:resource="vocab/reviews"/>
And a sample individual in my ontology looks like
<reviews_2:Review rdf:about="http://review-analyzer.local/ontologies/reviews_2.owl#tt2">
<reviews_2:isAbout rdf:resource="http://review-analyzer.local/ontologies/reviews_2.owl#amoled"/>
<reviews_2:comment>dfgh</reviews_2:comment>
<reviews_2:rating rdf:datatype="http://www.w3.org/2001/XMLSchema#integer"
>2</reviews_2:rating>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
Now the question is down to how do I combine these two RDFs to get data from SPARQL? can I do this using SWRL(Semantic Web Rule Language) ?

How to determine number of children of a record?

Good afternoon everyone!
I'm studying NHibernate, and decided to make some changes. Among them, I noticed that some fields are unnecessary. So I bring my doubt:
I have a list, let's call it Class_List within each study class, I can have N students for each class. Within the list Class_List, I also have other properties as simple as the name of the class.
How I see it is unnecessary to store how many students I have in the database, I would, in a single query, how many records I have. This, using NHibernate.
Is this possible? How?
Best regards,
Gustavo.
Edit: I've forgot to say one thing... I want to return this number of record, as a column. But this column is not mapped in my .hbm.xml file.
If students are mapped as a collection on Class, you can try using something like this:
var numberOfStudents = session.CreateCriteria<Class>()
.Add(Restrictions.IdEq(1))
.CreateCriteria("_students", "students")
.SetProjection(Projections.RowCount())
.UniqueResult<Int32>();
Where '1' is the id of the class (you can use other property) and '_students' is the name of the students collection.

What's the right way to make forms for creating/updating records with Single Table Inheritance (STI) in Rails?

If you have Single Table Inheritance in Rails something like this:
class Vehicle < ActiveRecord::Base
class Car < Vehicle
class Truck < Vehicle
What's the recommended way to create a single template which allows the user to create either a Car or a Truck from a single vehicles/new.html.erb? I think the tricky bit is how to lay out the html form so that BOTH car's and truck's fields are present, but when the POST occurs, the controller somehow knows to select the right form based on an html select or radio. I'm hoping someone a lot smarter than I has a great best-practices answer!!
Extra credit: the Vehicle is actually a nested association under a Person, so it is really Person#vehicle_attributes...