database design - Rails and Data Integrity -


i'm on fence on how implement models. right i'm using polymorphic relationships, feels wrong, though convenient. feel should making use of database level integrity enforcement added layer of security.

am grandpa questioning application layer? please discuss.

i did find post, not rails specific possible mysql foreign key 1 of 2 possible tables?

it depends.

if application 1 access database (e.g. there no other tools writing it), can verify data integrity in application code.

there things, however, still best done in database. validates_uniqueness_of example here. 2 app instances may report given value unique, there may race condition. having unique index in database here practice.

i handle integrity checking in app code, using indices uniqueness constraints. don't bother foreign_key relations, let activerecord handle that.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -