0

Google App Engine のリレーショナル データベースを再構築しようとしていますが、必要なデータを効率的にクエリできるように一連の関係をモデル化することに問題があります。

不自然な例として、次のモデルがあるとします。

class Rental(db.Model):
    # ancestor of one or more RentalDatas
    date = db.DateProperty()
    location = db.IntegerProperty()
    # + customer, etc

class RentalData(db.Model):
    # a Rental is our parent
    unicorn = db.ReferenceProperty(Unicorn, collection_name='rentals')
    mileage_in = db.FloatProperty()
    mileage_out = db.FloatProperty()
    # + returned_fed, etc

class Unicorn(db.Model):
    name = db.StringProperty()
    color = db.IntegerProperty()
    # 'rentals' collection from RentalData

各レンタルには複数のユニコーンが含まれている可能性があるため、できればRentalとモデルを組み合わせたくありません。RentalData私はほとんどの場合、指定された から始めUnicornます。たとえば、ユニコーンRentalDatarentalsコレクション内のすべてを反復処理して、親、ソートする日付を取得するだけです。

弾丸を噛んで非正規化する必要がありますか? で複製dateRentalData、必要に応じてparent()を使用して、Rentalプロパティが必要なときに対応するものを取得しようとしました。うまくいきますが、簡単な方法を取っているだけではないかと心配しています。

4

0 に答える 0