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

后端 未结 4 1080
我寻月下人不归
我寻月下人不归 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:07

    If you are looking for way's to design the datatable. I'd recommend you do a bit of research before you start the work. There are pretty magical properties for Google App Engine like :

    • Self-merge
    • Multi-valued list property

    That would be very helpful in your design. I've shared my experience here.

    To learn about scale-ability there is an exclusive free course in Udacity here just on the topic. It's taught by the founder of reddit.com and he clearly explains the whole scaling things happening in reddit, one of the sites with the highest number of visitors. He shows the entire course demo implementation in gae (and that was a jackpot for me!). They offer the entire course videos free to download here . I've been toiling hard with app engine before I got these resources. So I thought sharing this might help other who are stepping the foot in waters.

    0 讨论(0)
  • 2021-02-05 19:07

    Switching from a relational database to the App Engine Datastore requires a paradigm shift for developers when modeling their data. Take a look here to get a better idea. This will require you to think more up front about how to fit your problem into the constraints the datastore imposes, but if you can then you are guaranteed that it will run quickly and scale.

    0 讨论(0)
  • 2021-02-05 19:13

    Just because you don't have joins implemented by the DBMS doesn't mean you can't have multiple tables. In App Engine, these are called 'entity types', and you can have as many of them as you want.

    Generally, you need to denormalize your data in order to avoid the need for frequent joins. In the few situations where they're inevitable, you can use other techniques, like doing the join in user code.

    0 讨论(0)
  • 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
    
    0 讨论(0)
提交回复
热议问题