[storm] Does one have to create the one-to-many ref. is it's not neede in the object?

Gabriel Rossetti gabriel.rossetti at arimaz.com
Tue Jul 22 11:15:24 BST 2008


Hello everyone,

I am following the official tutorial and I have a small question.
In the one-to-many reference type, does it have to be defined if I don't 
need the attribute? If I created my database with a "user" and a "lang" 
table, their is a one-to-many relationship in between them, but in my 
python objects, the "User" object needs a one-to-one ref to the "Lang" 
class/table, but I don't need a ref to the "User" from the "Lang" class. 
Does Storm need for me to put it there so it knows how everything comes 
together? Here are the Tables :

User(id, fname, lname, lang_id)
Lang(id, name)

where "id" are primary keys and "lang_id" is a foreign key, and the 
classes are defines as the following :

class User(object):
    __storm_table__ = "user"
   
    id = Int(primary=True)
    fname = Unicode()
    lname = Unicode()
    langId = Int()
    lang = Reference(langId, Lang.id)

class Language(object):
    __storm_table__ = "lang"
   
    id = Int(primary=True)
    name = Unicode()
#    users = ReferenceSet(id, User.id)

Thank you,
Gabriel



More information about the storm mailing list