DB Table Constraints using code or not! Best practices?

FWIW, I use the foreign_key_migrations plugin which defines FK's in my migrations for me. I do this because:

1) I don't trust ActiveRecord to ensure my relations are sane 2) I don't always use ActiveRecord to interact with my DB

Aaron Turner wrote:

the Database? Or just simply keep it all loose and use :dependent ActiveRecord :depedent �Yes I know, but what are the best practices? how to you guys do it and why? scalability is one of the aims as well. I don't want Constraints on the tables to be in the way later.

Please let me know from your experience.

FWIW, I use the foreign_key_migrations plugin which defines FK's in my migrations for me. I do this because:

1) I don't trust ActiveRecord to ensure my relations are sane 2) I don't always use ActiveRecord to interact with my DB

I do likewise, for the same reasons. I understand there's now a similar plugin called Foreigner, but I've never used it.

-- Aaron Turner http://synfin.net/ http://tcpreplay.synfin.net/ - Pcap editing and replay tools for Unix & Windows Those who would give up essential Liberty, to purchase a little temporary Safety, deserve neither Liberty nor Safety.     -- Benjamin Franklin "carpe diem quam minimum credula postero"

Best,

Thanks alot guys for your input and suggestions.

Good points.

After researching about PostgreSQL which I might be using for the project, it is full of features that the db server can handle and automate rather than rely on Rails.

I will stick with the database relations then, it never fails but just thought of getting a different perspective.

thanks again

Bachir El khoury wrote:

Thanks alot guys for your input and suggestions.

Good points.

After researching about PostgreSQL which I might be using for the project,

Good choice. With PostgreSQL, you get referential integrity and a fast storage engine.

it is full of features that the db server can handle and automate rather than rely on Rails.

I will stick with the database relations then, it never fails but just thought of getting a different perspective.

You probably want to have the AR validations as well -- it makes error handling a bit easier.

thanks again

Best,