Project

General

Profile

Project Identifier - Data Constraint

Added by James H almost 9 years ago

Why isnt the project's identifier column designated as a "unique" constraint?


Replies (2)

RE: Project Identifier - Data Constraint - Added by Toshi MARUYAMA almost 9 years ago

"validates_uniqueness_of" is defined in model.
source:tags/3.0.3/app/models/project.rb#L75

RE: Project Identifier - Data Constraint - Added by James H almost 9 years ago

i understand that the application checks for that, but wouldn't it also be good to put that kind of constraint on the database layer?

constraints on the application side promote flexibility in the data model in case of future changes, and constraints on the database layer promote data integrity and minimizes data duplication.
I think in this case, you do not need the flexibility that the application-side "unique" constraint provides because i do not see any future case where you would allow duplicate identifiers. The database constraint will provide the same level of functionality while being slightly easier to maintain and providing the same kind of constraint across any kind of usage of the database (potential external applications?).

Just a thought.

    (1-2/2)