On Mon, 2008-02-18 at 15:39 +0200, svilen wrote:
> AFAIK, the polymorphic_identity value there is used:
>  a) for queries, to discriminate/switch between object-types
>  b) for inserts, to put _that value when inserting that object-type.
> 
> i.e. to me these values ought to be some consts, different for each 
> subtype in the hierarchy. As of sharing that functionality with 
> something else (why is it a FK?), i have no idea.
> 

Why a FK ? Because I have some additional fields which are associated
with a ContentType (like and icon, a description, ...) and because it's
better in the relational model point of view, no ? (... note that I
could set my key on a varchar field instead of an integer, it's just
that I usually use an integer for my pks/fks)

> > I'm busy to play with (joinded) inheritance in SQLAlchemy. I have
> > to design and implement a CMS-like app and my idea was to do
> > something like (it's the SQL script) :
> > http://pastebin.com/m35f5227d
> >
> > As you can see it's a classic inheritance situation: a base Content
> > (abstract) which is of a certain ContentType (the polymorphic_on),
> > and more specialized objects (News, Events, ...) inherits from this
> > base Content class.
> >
> > In the manual I read that :
> > "The table also has a column called type. It is strongly advised in
> > both single- and joined- table inheritance scenarios that the root
> > table contains a column whose sole purpose is that of the
> > discriminator; it stores a value which indicates the type of object
> > represented within the row. The column may be of any desired
> > datatype"
> >
> > In my situation the so-called "type" column is the
> > "content_type_id", which is foreign key, so for the News / Content
> > relation in this case I would have something like :
> >
> > mapper(Content, contents,
> > polymorphic_on=contents.c.content_type_id,
> > polymorphic_identity='?????')
> >
> > mapper(Engineer, engineers, inherits=Employee,
> > polymorphic_identity='?????')
> >
> > My question is: can I have a select() object which return a scalar
> > for the polymorphic_identity parameters ? I guess it should be
> > possible to put anything else than the FK value ?
> >
> > Thanks,
> > Julien
> 
> 
> 
> > 
-- 
Julien Cigar
Belgian Biodiversity Platform
http://www.biodiversity.be
Université Libre de Bruxelles (ULB)
Campus de la Plaine CP 257
Bâtiment NO, Bureau 4 N4 115C (Niveau 4)
Boulevard du Triomphe, entrée ULB 2
B-1050 Bruxelles
Mail: [EMAIL PROTECTED]
@biobel: http://biobel.biodiversity.be/person/show/471
Tel : 02 650 57 52


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" 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/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to