我需要什么变化来为AppEngine的BigTable工作? [英] What changes do I need for my tables to work on AppEngine's BigTable?

查看:160
本文介绍了我需要什么变化来为AppEngine的BigTable工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个由用户组成的预订数据库:

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

user_id
fname
lname

及其

ticket_id
user_id
flight_no

和相关的航班

flight_no
airline
departure_time
arrival_time

我需要更改以移动Google AppEngine?

我了解AppEngine 不允许加入

I understand AppEngine doesn't allow joins.

这是否意味着我的桌子应该成为一个巨大的混乱的场景?

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

预订

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?

推荐答案

你需要做什么改变主要取决于你需要运行什么查询,而不是你有什么数据。很可能你只需要添加一些东西。

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.

创建查询列表,然后查看查询限制。找到有问题的代码之后,请尝试使用BigTable的约束来重写它们。

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.

好的一面是BigTable强制你有一个非常可扩展的数据库设计。坏的一面是,当你不真正需要可扩展的设计时,它浪费了很多时间。

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.

这篇关于我需要什么变化来为AppEngine的BigTable工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆