jena - SPARQL query relates records like one-many -


i have type of model(schema)

1 product hasoffer (many) offers  1 offer hserule (many) shipment rules 

like

product(1)--->offer(n)----->rules(m) 

how can query 1 product offers , shipping rules. in simple words. how can query one-many related records ?

this can achieved using simple sparql query multiple triples in clause. works because graph model on sparql queries naturally joins data together.
eg.

select ?product ?offer ?rules   { {?product ns:hasoffer ?offer} {?offer ns:hasrules ?rules} } 

source: running same example in protege query.

edit:

question: there way construct product{ offers:{ rules:{} }, productattributes } ?

answer: yes there is, can add ?attribute select clause triple ?product ns:productattribute ?attribute where clause (or multiple such clauses if have attributes across multiple data properties).
recommend refrain doing so. query going return potentially large set of data similar sql result set. going see multiple rows same product , having product attribute there make life unnecessarily difficult, since attribute appear in rows product. instead run separate query products , attributes.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -