[Dbix-class] table referencing itself

Daniel McBrearty danielmcbrearty at gmail.com
Wed Dec 20 22:51:05 GMT 2006


that sounds like good advice. I'll take it. Simpler always wins out ...

thanks people. that got to the point pretty quick ...

On 12/20/06, John Napiorkowski <jjn1056 at yahoo.com> wrote:
>
> --- Brandon Black <blblack at gmail.com> wrote:
>
> > On 12/20/06, Daniel McBrearty
> > <danielmcbrearty at gmail.com> wrote:
> > > Is there a way to get the id of the object being
> > created in the
> > > statement doing the creation? I don't even know if
> > the db (postgresql)
> > > can do that ... ?
> > >
> >
> > AFAIK, postgres doesn't support doing this easily
> > for an autogenerated
> > SERIAL column.
> >
> > This type of statement does work however:
> >
> > insert into whatever values
> > (nextval('public.tree_nodeid_seq'::text),
> > currval('public.tree_nodeid_seq'::text), .....);
> >
> > Of course, if you really are making a tree or graph,
> > and
> > self-reference is just a way to say "root-level
> > node", I'd say just
> > make it nullable and treat nulls as root-level nodes
> > and have an
> > easier life.
>
> I would have to agree with this sentiment.  I have a
> number of self-referencing tables and trying to make
> the FK not null is a serious hassle.  I found it
> greatly complicated even basic development tasks, like
> creating triggers for no particular gain.  So unless
> you have a really compelling business need to do it
> the way you've outlined I would recommend against it.
>
> --john
> >
> > -- Brandon
> >
> > _______________________________________________
> > List:
> >
> http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
> > Wiki: http://dbix-class.shadowcatsystems.co.uk/
> > IRC: irc.perl.org#dbix-class
> > SVN:
> >
> http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
> > Searchable Archive:
> >
> http://www.mail-archive.com/dbix-class@lists.rawmode.org/
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> _______________________________________________
> List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
> Wiki: http://dbix-class.shadowcatsystems.co.uk/
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
> Searchable Archive: http://www.mail-archive.com/dbix-class@lists.rawmode.org/
>


-- 
Daniel McBrearty
email : danielmcbrearty at gmail.com
www.engoi.com : the multi - language vocab trainer
BTW : 0873928131



More information about the Dbix-class mailing list