by nl · 14y ago · 0 comments
In CouchDB, if you want to change your schema you just save the new data.
Your code will have to handle the old and the new form, but that is always true. In CouchDB the data is just a JSON document, so handling the changed model is about as easy as it gets.
What am I missing?
You may have an old form you can't change.
For example:
- 10 apps connected to the same database. Changing the model breaks 10 apps. And you may not have access to change the code to any of those apps.
- In healthcare, when either the database or app go down people literally die.
This isn't as easy as it gets: no database vendor has a solution for this to date.
(Edit: formatting)
I'm not sure what your point is. As you say, this is hard, and no one else has a solution either.
But the nature of CouchDB can help here - views can be used to create backward compatible versions of new data, and reading a JSON document with extra fields won't break existing code.
It's true it's not magic, though, if that is what you are after.
Edit: I see now you are working on http://chronicdb.com/ which looks like it tackles this problem.
10 apps connected to the same database. Changing the model breaks 10 apps. And you may not have access to change the code to any of those apps.
"Database as an integration layer" is an antipattern that should always be avoided (except possibly in the case of reporting applications). CouchDB isn't unique there.
In healthcare, when either the database or app go down people literally die.
Yes, and? CouchDB is reliable, distributable, etc etc. If your point is that you should be careful when you upgrade, then yes, I agree.
Also, what makes you say that database as an integration layer should always be avoided?
15 years of writing software. Every time I've had to deal with a shared database it has caused problems, and every time I've built a system avoiding that antipattern it has worked much better.
But it's not just me, here's some references:
Enterprise Integration Anti-Patterns # - The Shared Database: http://ianfnelson.com/archives/2010/11/08/shared-database/
Database as an IPC Antipattern (which is a subset of the broader shared database antipattern): http://en.wikipedia.org/wiki/Database-as-IPC
There is a good reason why SOA was created, and why exposing applications' data via defined interfaces is very popular.
(I should have included this link in my other reply on problems with updating aggregated queries).
New apps will have to deal with old versions somehow, or some back-end job will produce new data out of the old.
If one suggests old data and new data be stored separately then the door to data inconsistency opens.