On Wednesday 30 September 2009 21.58:55 Kevin Horn wrote:

> > I have a table "Entry" and a table "EntryFlags" (1:1 relation from
> > EntryFlags to Entry).  The idea is that while there is a large number
> > of "Entry" rows only a small number has flags set (and thus needs an
> > entry in EntryFlags; note that they don't need to be booleans, despite
> > the name).
> >
> > So having a separate table for the EntryFlags keeps the rows of Entry
> > smaller and should also speed up if I select by certain flags.
> >
> > How do I represent this in sqlalchemy?
> >
[...]
> > the columns from the
> > EntryFlags table appear in Entry as if they were inline, returning a
> > default value where an EntryFlags column doesn't exist.  (Bonus for
> > removing the EntryFlags row if all values are back to default ;-)

> Check out the "Customizing Column Properties" in the Mapper Configuation
> docs:
> http://www.sqlalchemy.org/docs/05/mappers.html#customizing-column-propert
> ies
> 
> If I understand correctly, this should do what you want.
> (Disclaimer: haven't done it myself, YMMV)

Hmm.  Mapping an outer join to my actual model class would be part of it.  
Not sure how to easily assign default values for the part of the row not 
backed by a real row on the "EntryFlags" side (they shouldn't just be NULL; 
default values on the EntryFlags table wouldn't be of much use since they'd 
be applied only when the row would be generated and not for access to the 
outer join, afaict)

(And as an aside: this has become a a bit an academic question for now, I've 
thought about more about what I'm trying to do and redesigned the schema.)

cheers
-- vbi

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

-- 
Do you understand now why we attacked Iraq?  Because war is good for the
economy, which means war is good for America.   Also, since God is on
America's side, anyone who opposes war is a godless un-American Communist.
        -- excerpt from one of those 'joke' mails floating around.

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to