How about something like this? class User { Long id; ... }
class Deck { Long id; Long userId; ... } class Card { Long id; Long deckId; ... } Then inserting a card into the deck is a simple insert and finding all cards in a deck is a single query. The same for adding a deck to a user. This structure has its own trade-offs, of course. On Mar 10, 4:15 pm, tempy <fay...@gmail.com> wrote: > Exactly, CardList is potentially very large and I want to avoid having > to load it just to add the cardreference. > > On Mar 10, 10:43 pm, WillSpecht <willspe...@gmail.com> wrote: > > > So if you have a reference to a new card and do > > > cardList.add(cardRefference) > > > all you are loading into memory is the card list and the new card. > > > Is this what you are trying to avoid? > > > On Mar 10, 4:06 pm, tempy <fay...@gmail.com> wrote: > > > > Actually cards can only be owned by one deck... so that's not a > > > problem. Deck<--1...0toN-->card. > > > > The thing that I am looking for is a way to add new cards without > > > loading a deck's entire card collection, and to add decks without > > > loading a User's entire deck collection. > > > > On Mar 10, 9:15 pm, WillSpecht <willspe...@gmail.com> wrote: > > > > > The way I understand it, if an object can be owned by more than one > > > > object it must be unowned. I would assume that cards can be in > > > > multiple decks so they must be unowned. I would assume each deck > > > > would belong to one user so decks could be owned. I don't know a good > > > > way to store cards that can be queried in one query unless you have > > > > each card store what decks they are in. This could be even more > > > > difficult if cards appear more than once in a deck. If that is true I > > > > would suggest a join table. > > > > > On Mar 10, 2:20 pm, tempy <fay...@gmail.com> wrote: > > > > > > I have the following datastructure: > > > > > > "Users" are the root entities, and each "user" can have one or more > > > > > "decks", and each deck can have one or more "cards." > > > > > > When a user wants to add a deck, I would like to be able to add the > > > > > deck to the user's collection of decks without first fetching all of > > > > > the user's decks (potentially a large amount of data), then adding the > > > > > new deck to that collection, and then persisting the user. Rather, I > > > > > would like to simply instantiate the deck and append it to the user's > > > > > collection of decks, without ever retrieving the entire collection. > > > > > > Similarly, if a user wants to add a new card to an existing deck, I > > > > > would like to add the card to the deck without first retrieving the > > > > > entire deck (that is, the deck with all of its cards). > > > > > > I would like to preserve the option of fetching a user with a > > > > > populated collection of all their decks and to retrieve a deck with a > > > > > populated collection of all its cards, which is possible with owned > > > > > relationships. But to accomplish what I have mentioned above, would I > > > > > be forced to use unowned relationships? (Collections of keys instead > > > > > of collections of objects.) > > > > > > Thanks, > > > > > Mike -- 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-j...@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.