[Rails] Re: does rails enforce referential integrity???
Łukasz Piestrzeniewicz
bragi.ragnarson+rf at gmail.com
Sun Aug 13 21:49:25 GMT 2006
Francis Cianfrocca wrote:
> Łukasz Piestrzeniewicz wrote:
> > Skip the db constrains and use Rails validations to achive
> referential
>> integrity:
>>
>
> This may indeed be the correct answer to the OP's question but you
> realize that by not building RI into the data model, you're making it
> somewhat more difficult to re-use this database for other applications.
> (At minimum, another application will need to code the same RI
> constraints and you will need to transmit this knowledge outside of the
> data model.) Generally speaking, is that all right with you?
>
> It's clear that RoR favors a style in which the data are defined along
> with the application- that's a clear bias of the framework- but are we
> also saying that databases are to be considered purpose-build components
> for specific applications? Just curious what people's opinions are.
I am a very simple man. I learned about encapsulation and I use it
successfully. Encapsulation is about not exposing internal data.
Application is an object so it also must obey encapsulation. If you want
two applications to share data then one of them must be responsible for
storage. The other one can access only the API that the first one
exposes. You have several options and REST webservices are probably the
most simple to implement.
Databases are awful at being more than just a storage engine. If it
would be possible to use database to enforce complicated business rules
in simple, fast and easy to maintain way, we would not need ActiveRecord
in the first place.
The best thing is to forget about all those 'features' that database
manufacturers advertise and use databases for the only purpose they were
created: to store data.
Once you stop thinking in salesman categories you will see the light ;)
Cheers,
Bragi
--
Posted via http://www.ruby-forum.com/.
More information about the Rails
mailing list