::scr Data integrity and why databases suck

Simon Kinahan scr@thegestalt.org
Thu, 7 Feb 2002 12:14:41 -0000


> Hmm... I've got complex objects that'd require joins. Almost anything
> that maintains a list of objects will need it.

Well, kinda. Anything that needs a list of objects needs a foreign key on
the target object that refers back to it. The obvious way to traverse that
relationship is to do a join, but as long as nothing nasty is going on, you
can usually get away with just querying one table or the other, no join
required.

If you use CMP, or some other tool that generates your DB schema from your
object model, it will usually make use of this optimisation and you'll find
the queries it generates are join-free.

If you've got a really complex object, that is in itself spread over several
tables, then yes, you need to do joins.

Simon