On Wed, 2007-04-04 at 16:47 -0700, TaMeR wrote:
> I have done something like this before with php & mysql creating all
> my own sql statements but I am getting a bit confused with the
> ForeignKey and ManytoMany fields.
> I like to create following models:
>
> Organizations: May be the users Company or one of many clients
>
> People: May be a users info or one of many contact person for one
> Organization.
>
> Address: May be People or Organizations
>
> Phone# Can be Phone, FAX, Mobile etc. for either People or
> Organizations
>
> Where do I place my ForeignKey and ManyToMany fields?
> Also, lets take Organization as example: where do I place the select
> box which indicates if it is owned by user, a client or a vendor etc.
One approach:
- People has a ForeignKey(Address) -- assuming only 1 address
per person, otherwise use ManyToManyField.
- Organization has a ForeignKey(Address)
- Both People and Organization have ManyToManyField(Phone#)
- Phone number field contains a field to describe what type of
phone number it is (landline, fax, mobile, ...)
The People to Organization link can be done through an intermediate
table, as in [1]. This allows you to put an attribute on the
intermediate table indicating the type of relationship (owner, customer,
etc).
[1] http://www.djangoproject.com/documentation/models/m2m_intermediary/
Regards,
Malcolm
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" 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/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---