Modeling Entity relationships with GAE/Java

26 views
Skip to first unread message

cyberquarks

unread,
Mar 30, 2021, 5:49:28 AM3/30/21
to Google App Engine
Using the native GAE DatastoreService: `com.google.appengine.api.datastore.DatastoreService`

How can you model the following relationships:

 - One-to-Many
 - Many-to-One
 - Many-to-Many
 - One-to-One

goya

unread,
Apr 8, 2021, 9:24:25 AM4/8/21
to Google App Engine

There is no such thing as relationships in Datastore, because Datastore is a No-SQL database and relationships are a SQL databases concept [1].


Depending on your app, you have two options to “relate” properties in different parts of the database:

1- Copy the data from one entity to another entity you want to get the data from

2- Perform multiple requests to get all the data needed separately and manage it in your code


This video explains more in depth what you should take into consideration when designing a database in Datastore (video is about Firestore, but the same can be applied to Datastore).



[1]: https://cloud.google.com/datastore/docs/concepts/overview#comparison_with_traditional_databases 

[2]: https://youtu.be/v_hR4K4auoQ?t=303 

Reply all
Reply to author
Forward
0 new messages