I’m designing my application data model and I have a doubt, whether to use parent or a simple index.
Site{
@Id Long id;
}
Booking{
@Id Long id;
@Index/Parent Key<Site> site;
@Index Date date;
}
My 2 entities are Bookings and Sites. The relationship is that a Site has many Bookings.
I want to retrieve bookings in 2 ways: getBookingBySiteAndDate(Key site,Date date) and getBookingsByDate(Date date)
The s*econd query* is not efficient if I use Parent since I need the Booking’s site to retrieve all the bookings. This Site might have been deleted.
The first query is not efficient if I use Index since I need a custom index in (date, site) and is costly. Appart of that the creations are not consistent since the bookings don’t have entity group and I have a limitation of 1w/s.
What is your advice ?
I’ve double checked in the Objectify mailing list and there is no restriction to use getBookingsByDate with Parent and without Site Id.
The solution they recommended me is to use @Parent since is faster and you don’t need a double index on Site-Date.