On 26 jan, 12:41, Adrian Bool <a...@logic.org.uk> wrote:
>
> I'm defining the DB in Python; using objects and inheritance.  As such, when 
> I'm doing this I'm thinking in an object orientated (OO) manner - a service 
> uses a number of resources so I create a Service object with with either 
> foreign key or many-to-many (as appropriate) relationship to the Resource 
> objects.  This gives me nice referential integrity and I can be sure that the 
> Service has valid connections to the Resources it requires.
>
> It seems, however, that Django expects the models not to be defined in an OO 
> manner.  For example; should I wish resources to be listed as Inlines on the 
> Service's page  I can only do this if the foreign key is with the Resource - 
> pointing 'up' the stack to the services - as possible to being pointed to by 
> the Service.  Django seems to be defining stricture using an OO language; but 
> expecting that structure in a more traditional, relational database, style 
> where entries point up to their owners rather than the owners pointing down 
> to their children.

That's indeed how a relational DB works, and Django's ORM doesn't try
to pretend the relational DB doesn't exists or is just a dumb 'bit
bucket'. So, while models ares defined as classes, these are mostly -
from this POV at least - "technical" objects wrapping the relational
model, and not "pure" OO domain objects (whatever a "pure" OO domain
object might be). This doesn't mean you have to go for an "anemic
domain model" neither - your relational schema is part of the "domain
space", and models (as well as managers) are also here to support
additional responsabilitie.

Some will talk about "OO/relational impedance mismatch" (ok, I cheated
- Daniel just did;)), but I don't see it that way as far as I'm
concerned - I'm using a relational model wrapped into an OO
representation, and that's just what I want for most apps.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to