Hi Sam. It may be somewhat redundant, but if you include a list property
with the two endpoints (in addition to the from and to properties), you can
do a reasonably efficient query to find all edges connected to A. Or, if you
know in advance which nodes you are interested in, you can keep track of
these when new edges are added so you don't have to query at all. So there
are numerous ways to tackle this problem.
- Jason

On Sat, Aug 22, 2009 at 1:27 PM, Sam Walker <am.sam.wal...@gmail.com> wrote:

> Hi Jason,
>
> I want to do a query like: Find all relationships in which A is involved. I
> think I cannot do anything like filter(A.key in key). So the only way is to
> do something like: filter(from = A.key & fromAttribute = false) + filter(to
> = A.key & toAttribute = false) (1st model in original post) or filter(both =
> A.key) followed by filtering the attributes from the result (second model in
> original post). Is this the best way? Just felt a bit ugly thats why I
> wanted to double check.
>
> Constructing the key by concatenating keys of A and B will ensure that I
> dont have multiple of Relationships between A and B.
>
> Thanks.
>
>
> On Thu, Aug 20, 2009 at 12:17 PM, Jason (Google) <apija...@google.com>wrote:
>
>> Hi Sam. Are you saying that, given two node names, you want to see if
>> there's an edge between them? In that case, couldn't you concatenate the two
>> node names, putting the smallest one first, and doing a direct get to see if
>> an entity is returned? If you get a result, that means there is an edge from
>> A-B, otherwise you'll get null (JPA) or trigger an exception (JDO).
>>
>> Or are you asking how you'll access the individual nodes given that the
>> key is a concatenation. If this is your question, I'd recommend keeping A
>> and B as separate entities and creating a new kind for edges. Then you can
>> still get the individual nodes back and easily find whether any two nodes
>> are connected or not using my suggestion from the first paragraph. Does this
>> answer your question?
>>
>> - Jason
>>
>> On Wed, Aug 19, 2009 at 10:42 PM, Sam Walker <am.sam.wal...@gmail.com>wrote:
>>
>>> I want to create a key for this relationship, lets say if A -> B exists,
>>> B -> A cannot exist together. I was thinking of concatenating key A and key
>>> B, sth like A-B. I make sure the smallest key is first, so that I dont have
>>> any B-As.
>>>
>>> But, how would I do a query for the two entitites? Is the only solution
>>> to have extra ArrayList<Key> or Key from, Key to attributes and put them in
>>> the criteria?
>>>
>>>
>>> On Mon, Aug 10, 2009 at 5:08 AM, objectuser <kevin.k.le...@gmail.com>wrote:
>>>
>>>>
>>>> If that's as complex as your queries get, I'd recommend just doing to
>>>> queries and merging the results.
>>>>
>>>> Also, if the semantics of fromAttribute and toAttribute are different,
>>>> then you've lost that in your second model.
>>>>
>>>> On Aug 9, 10:45 pm, Sam Walker <am.sam.wal...@gmail.com> wrote:
>>>> > I have a directed graph scenario and I want to model the relationship
>>>> with
>>>> > App Engine data store.
>>>> >
>>>> > Relationship {
>>>> >   Key from;
>>>> >   Key to;
>>>> >   boolean fromAttribute;
>>>> >   boolean toAttribute;
>>>> >
>>>> > }
>>>> >
>>>> > I want to do this query: where (from = <key> and fromAttribute =
>>>> > <attribute>) or (to = <key> and toAttribute = <attribute>). Ors are
>>>> not
>>>> > allowed. So, I am not sure how to do it. I am now thinking of doing:
>>>> >
>>>> > Relationship {
>>>> >   ArrayList<Key> both; // Will always have two keys
>>>> >   ArrayList<boolean> attributes;
>>>> >
>>>> > }
>>>> >
>>>> > Now, I could change the query to: where <key> in both, and then check
>>>> for
>>>> > respective attributes, but that's kinda ugly.
>>>> >
>>>> > I am sure there will be a better way, please help.
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to