Polymorphic fields, PostgreSQL, and delete constraints


Say I have:

class Relationship < ActiveRecord::Base
belongs_to :parent, :polymorphic => true

and then several models like:

class Person < ActiveRecord::Base
has_many :parents, :as => :parent, :class_name => “Relationship”

I do not want to allow a person to be deleted if they are still being
used by a relationship. I think I could come up with a way to do this
with Relationship.find(:first. Probably return just the id. If I get
anything back, the validate method could fail. Something like that.

But I’m wondering if using “rules” inside of PostgreSQL would be
significantly faster? I have never done rules so I’m a little timid.

Any advice?

Thank you,