Ok, maybe I'm answering my own question -- but I have not idea if it
is correct.
class Addresses(Entity):
using_options(tablename='addresses')
custnmbr = ManyToOne('Customers', Unicode, primary_key=True)
adrscode = Field(Unicode, primary_key=True)
address1 = Field(Unicode)
class Customers(Entity):
using_options(tablename='customers')
custnmbr = Field(Unicode, primary_key=True)
custname = Field(Unicode)
...
addresses = OneToMany('Addresses')
elixir will successfully create the tables and relationships, but have
I done what I was trying to do?
Specifically, is the forward relationship proper?
On Feb 22, 3:23 pm, dundeemt <[EMAIL PROTECTED]> wrote:
> I've been through the tutorial and I'm attempting to construct a 1-
> Many relationship between Customers.custnmbr ~ Addresses.custnmbr
>
> Here is some sample code(no relations).
>
> class Addresses(Entity):
> using_options(tablename='addresses')
>
> custnmbr = Field(Unicode, primary_key=True)
> adrscode = Field(Unicode, primary_key=True)
> address1 = Field(Unicode)
> ...
>
> class Customers(Entity):
> using_options(tablename='customers')
>
> custnmbr = Field(Unicode, primary_key=True)
> custname = Field(Unicode)
> ...
>
> The 1-Many forward relation would seem to be:
> class Addresses(Entity):
> using_options(tablename='addresses')
>
> custnmbr = Field(Unicode, primary_key=True)
> adrscode = Field(Unicode, primary_key=True)
> address1 = Field(Unicode)
>
> class Customers(Entity):
> using_options(tablename='customers')
>
> custnmbr = Field(Unicode, primary_key=True)
> custname = Field(Unicode)
> addresses = OneToMany(Addresses)
>
> but I can't seem to figure out the back relationship that would be
> needed. I apologize if this is already answered on the list but I
> couldn't seem to find it -- probably wasn't searching for the correct
> term. It's my first crack at ORM
>
> Jeff
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"SQLElixir" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---