Scott, Thanks again. The simple scenario you've outlined I understand. What I was going for is:
Show me a list of users who have more than 1 forum they follow in common. If I get that, then how many forums do they share in common (count) Kevin On May 14, 10:29 am, Scott Henninger <[email protected]> wrote: > Kevin; Unless you need to use aggregate in your query, sub-selects are rarely > needed. The key to understanding SPARQL is that it is a mirror of RDF. Each > triple represents an edge in a graph. Using variables creates a graph > pattern that is matched against the RDF graph. > If what you want are the people following the same forum, you can visualize > this as a forum as the central node of a graph and finding all people > following that forum. Then filter out all cases where it's the same person. > SELECT ?person1 ?forum ?person2 > WHERE > { ?person1 sioc:follows ?forum . > ?person2 sioc:follows ?forum . > FILTER (?person1 != ?person2) . > } > To get a count of the number of people following a forum use the count > aggregate, grouping by the forum matches: > SELECT ?forum count(*) > WHERE > { ?person1 sioc:follows ?forum . > ?person2 sioc:follows ?forum . > FILTER (?person1 != ?person2) . > } GROUP BY ?forum > -- Scott > On 5/14/10 7:35 AM, Kevin wrote:Scott, Thanks for your reply. I did some > research and found a fitting solution. My near goal is accomplished by the > following query: (find people who follow more than one of the same forums) > SELECT DISTINCT ?person1 ?forum1 WHERE { ?person1 sioc:follows ?forum1 . { > SELECT ?person2 ?forum1 WHERE { ?person2 sioc:follows ?forum1 . } } ?person1 > sioc:follows ?forum2 . { SELECT ?person2 ?forum2 WHERE { ?person2 > sioc:follows ?forum2 . } } FILTER (?forum1 != ?forum2) . FILTER (?person1 != > ?person2) . } If you can simplify that query, that would be nice. Also I'm > looking for a way to capture the count. (ie tell me how many of the same > forums a pair of people follow). On May 13, 5:31 pm, Scott > Henninger<[email protected]>wrote:Kevin; Not sure what is meant by > "...where ?p1 and ?p2 are different ". For your query to work, there needs > to be a triples with an explicit owl:differentFrom property. The query you > give should work, and is equivalent to the following (that has many > advantages other than being simpler): SELECT ?p1 ?p2 ?f WHERE { ?p1 > sioc:follows ?f . ?p2 sioc:follows ?f . ?p1 owl:differentFrom > ?p2 . } -- Scott On May 13, 1:41 pm, > Kevin<[email protected]>wrote:Running sparql in topbraid composer the > following doesnt work:SELECT ?p1 ?p2 ?f WHERE { ?p1 sioc:follows ?f . > { SELECT ?p2 ?f WHERE { > ?p2 sioc:follows ?f . } } ?p1 > owl:differentFrom ?p2 .}If I remove the line ?p1 owl:differentFrom ?p2 . it > returns a list of results include ones where ?p1 and ?p2 are different-- You > received this message because you are subscribed to the Google Group > "TopBraid Suite Users", the topics of which include TopBraid Composer, > TopBraid Live, TopBraid Ensemble, SPARQLMotion and SPIN. To post to this > group, send email [email protected] unsubscribe from this > group, send email [email protected] more > options, visit this group > athttp://groups.google.com/group/topbraid-users?hl=en-- You received this > message because you are subscribed to the Google Group "TopBraid Suite > Users", the topics of which include TopBraid Composer, TopBraid Live, > TopBraid Ensemble, SPARQLMotion and SPIN. To post to this group, send email > [email protected] unsubscribe from this group, send email > [email protected] more options, visit this > group athttp://groups.google.com/group/topbraid-users?hl=en > > -- > You received this message because you are subscribed to the Google > Group "TopBraid Suite Users", the topics of which include TopBraid Composer, > TopBraid Live, TopBraid Ensemble, SPARQLMotion and SPIN. > To post to this group, send email to > [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group > athttp://groups.google.com/group/topbraid-users?hl=en -- You received this message because you are subscribed to the Google Group "TopBraid Suite Users", the topics of which include TopBraid Composer, TopBraid Live, TopBraid Ensemble, SPARQLMotion and SPIN. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/topbraid-users?hl=en
