Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top