Without joins on Google App Engine, does your data have to exist in one big table?

后端 未结 4 1081
我寻月下人不归
我寻月下人不归 2021-02-05 18:42

Since Google App Engine doesn\'t permit joins, does this mean that I have to take all of the tables in my web app and figure out a way of combining them into a single huge table

4条回答
  •  一向
    一向 (楼主)
    2021-02-05 19:14

    Combining it to one big table is always an option, but it results unnecessarily large and redundant tables most of the time, thus it will make your app slow and hard to maintain.

    You can also emulate a join, by iterating through the results of a query, and running a second query for each result found for the first query. If you have the SQL query

    SELECT a.x FROM b INNER JOIN a ON a.y=b.y;
    

    you can emulate this with something like this:

    for b in db.GqlQuery("SELECT * FROM b"):
      for a in db.GqlQuery("SELECT * FROM a WHERE y=:1", b.y):
        print a.x
    

提交回复
热议问题