1

私は次のリレーショナルスキーマを持っています(たとえば、MySQL、それは本当に私の頭の中にあります):

Login, Customer, Friendship, Address, Child, School

そのような

Login(username, password)
Customer(id, firstName, lastName)
Friendship(customer_id, customer_id) //many to many
Address(customer_id, street, city, state, zip)
Child(id, firstName, lastName, customer_id, school_id)//each customer may have many children
School(id, name, city, state, zip)// there are many children per school

スキーマをGoogleAppEngineハイレプリケーションデータストア(HRD)スキーマとして書き直したい:誰かがそれを行う方法を知っていますか?

これが私が得た限りです:

class Login(db.Model):
 username = db.StringProperty()
 password = db.StringProperty()

class Customer(db.Model):
 first_name = db.StringProperty()
 last_name = db.StringProperty()

class Address(db.Model):
 # what goes here?

class Friendship(db.Model):
 # what goes here?

class Child(db.Model):
 # what goes here?

class School(db.Model):
 # what goes here?

私はPython2.7を使用しています。

4

1 に答える 1

1

まず、ndbの代わりに使用することをお勧めしdbます。詳細については、ドキュメントを確認してください。

標準の文字列プロパティが不足しているようですが、これは主に必要なものです。

他のモデルを参照するモデルについては、KeyProperty例えばを使用することができます

from google.appengine.ext import ndb

class Friendship(ndb.Model):
  first_friend = ndb.KeyProperty(kind=Friend)
  second_friend = ndb.KeyProperty(kind=Friend)
于 2012-11-22T19:13:11.600 に答える