What changes do I need for my tables to work on AppEngine's BigTable?

人走茶凉 提交于 2019-12-04 13:42:42

问题


Let's say I have a booking database consisting of users:

user_id
fname
lname

and their tickets

ticket_id
user_id
flight_no

and associated flights

flight_no
airline
departure_time
arrival_time

What would I need to change to move this Google AppEngine?

I understand AppEngine doesn't allow joins.

Does that mean my table should become one big schmudge of fields all lumped together?

bookings:

user_id
fname
lname
ticket_id
flight_no
airline
departure_time
arrival_time

In other words, all of my queries now run against the same table?


回答1:


What changes you need depends mostly on what queries you need to run, not on what data you have. Most likely you will only have to add a couple of things.

Make a list of queries and then take a look at Restrictions on Queries. After you've found the problematic ones, try to rewrite them with BigTable's constraints in mind.

For example, if you often need to find the number of tickets for a list of flights, you won't just be able to do:

SELECT
    flight_no, COUNT(*)
FROM
    flights
JOIN
    tickets ON tickets.flight_no = flights.flight_no
GROUP BY
    flight_no

So you'll need to add a counter of tickets to flights and increment/decrement that when creating/deleting tickets.

Good side of this is that BigTable forces you to have a very scalable database design. Bad side is that it wastes a lot of your time when you don't really need a scalable design.




回答2:


You can use genuine SQL relational databases from Google appengine apps, through a webservice.

One such webservice is Rdbhost, at http://www.rdbhost.com .

It involves its compromises, particularly speed, in that each page view requires another backend http page request to the db server, but it allows you to use the SQL design knowledge you already have.



来源:https://stackoverflow.com/questions/731147/what-changes-do-i-need-for-my-tables-to-work-on-appengines-bigtable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!