The Siren Call of the Database
Posted by Dan Creswell in Architecture, Distributed Systems, Enterprise SystemsWhen we write programs one of the things we seek to do is encapsulate our data so as to allow us to manage our dependencies and keep our code clean. Most languages OO or otherwise provide mechanisms to support this way of working.
The thing about the average database is that it doesn’t really encourage similar behaviour. It is all too tempting (and easy) to just allow everyone to access everything. Whilst we confine ourselves to a single application using the database, the problem is to some extent contained but often what we actually do is allow multiple applications access to the same database. The exact way in which this is done varies:
- Sometimes we bundle all our middle tier code together even though it has separate roles and responsibilities and integrate all of it via a single database.
- Sometimes we have multiple applications each running in a different process.
With each application we put on top of the database the problem gets worse increasing the number of invisible dependencies tying unrelated elements of code together by virtue of accessing a shared schema.
What’s happening is we’re sharing too much intimate knowledge across our system, something we’re all taught to fear. The solution is as always to prevent direct access to this intimate knowledge by interposing layers of abstraction. One way to do this is by requiring access to data to be wrapped up behind an interface. Historically we’ve done this by having a system own the database and expose interfaces that other systems can use to get the data.
Unfortunately there is a well-known issue with this approach which is that the level of granularity is wrong and these additional integration interfaces rapidly balloon into complex beasts. What we need is a a database wrapping entity that has a finer level of granularity than an entire system. Then the integration interfaces will be simpler because there will naturally be a less complex schema underpinning this more limited functionality.
What are we talking about? Services. We end up with a system of lots of discrete services each wrapping up their own data storage.
There are other benefits to this approach:
- Each service can utilize the most appropriate storage option for it’s contained data whilst having zero impact on other services that might have different needs.
- Each service is an independent entity that can be managed (monitored, deployed etc) separately.
- Centralized access patterns are more easily broken down which is useful in cases where we deploy across multiple data-centres.
Who would do such a thing?
Technorati Tags: architecture, database, distributed systems, enterprise

Entries (RSS)