About crossing support boundaries
Stefan has explained why developers shouldn't query the MCMS database. It's excellent advice. Here's my take on why it should not be done:
Once we had a query that returned stuff from the MCMS database. You know, things like - searching resources in the gallery by their display name - it's not possible to do tasks like that efficiently with just the PAPI alone.
As time went on (of course, we didn't care about support because we weren't planning to get it for that application - it wasn't that important then), the database grew and grew and soon we had tens of thousands of resources in the gallery.
What happened later was a night mare - ocasionally, the database will get locked up and the website will literally timeout at each request that requires a query to the db. At that point, of course, the phones will start ringing and someone will reset the web service on the affected server. Then there will be peace for a while until disaster strikes again.
There are very good reason why MCMS comes with internal caching mechanisms to help speed up retrieval of data from the database. Bypassing it is not a good idea.
It's not worth the pain. Believe me - the alternatives are worth looking into.
Or at least work on a copy of the database as Andrew has suggested.