[jifty-devel] Referential integrity

Edmund von der Burg evdb at ecclestoad.co.uk
Thu Mar 8 13:39:57 EST 2007


On 08/03/07, myshare <mraptor at gmail.com> wrote:
> column fkid => refers_to YourApp::Model::Table;
>
> works in this situations ?

No - this creates the links so that you can go $book->author->name but
it does not do anything to enforce the presense of the author as long
as it is referenced from the book table.

CHeers,
  Edmund.

> On 3/8/07, Edmund von der Burg <evdb at ecclestoad.co.uk> wrote:
> > Hello,
> >
> > I want to create a setup where it is not possible to delete an object
> > in one class if it is being referenced from another class. Eg say I
> > have boks and authors, I want to prevent deletion of an author if
> > there are books by that author in the database.
> >
> > What is the best way to do this?
> >
> > I could add foreign key links in the database but that might not be
> > portable (I am on postgres).
> >
> > I could add code to each model class to check before deleteing but
> > that would be cumbersome. Rather I'd like Jifty to enforce this sort
> > of relationship if a 'references' column is marked as 'mandatory'. ie
> > in Book.pm the 'author' would be marked as 'is mandatory'. Hence
> > deleteing the books author would leave the book in an invalid state so
> > the deletion of the author should be prevented.
> >
> > Am I missing something?
> >
> > Cheers,
> >   Edmund.
> >
> _______________________________________________
> jifty-devel mailing list
> jifty-devel at lists.jifty.org
> http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel
>


-- 
In reality I'm evdb at ecclestoad.co.uk - http://ecclestoad.co.uk


More information about the jifty-devel mailing list