Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 359
karl Avatar asked Mar 01 '23 20:03

karl


2 Answers

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.

like image 76
Jaka Jančar Avatar answered Mar 03 '23 15:03

Jaka Jančar


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.

like image 39
Rdbhost Avatar answered Mar 03 '23 15:03

Rdbhost