Pat Gunn (dachte) wrote,
Pat Gunn

  • Music:

Databases, tuple-objectification, and stored procedures

In programming with databases, we are fortunate that modern databases usually use SQL as their language, and that we have a well-developed literature to guide people towards table-relations as thin and well-defined as possible. People immersed in best practices have reasonably normal databases (normal is a term of art - if you don't understand it, go look it up - good stuff). This is great for consistency, but sometimes inconvenient for queries, which often want to think of the table as denormalised (nevermind that the least normal tables, particularly those that try to incorporate one-to-many relationships, are very unpleasant to query). One of the goals of object database design is to try to accurately capture the structure of what clients outside the database think of when they instantiate and populate objects through database queries - provided there really is a single representation and single client, it can be more efficient to abandon SQL representations and use the database as a data store (whether the rest of ACID is useful or not might depend on the application). The problem with object databases is that they usually tend to suck at SQL.

If we tenatively agree with:

  • the premise that we usually (but not always) have the same class, instantiated from certain tables (and pushing back to them)
  • we are going to be writing a fair number of queries manually
  • we would like some syntactic sugar to make it easier to work with that so we're not always manually using relational algebra or relational calculus to glue tables together based on the same rules every time
  • we still want our databases to be normal
  • good SQL performance is essential
What are we to do? First, what would good syntactic sugar look like? Ideally it would let us eliminate a lot of the unnecessary flexibility and verbiage to glue together things that almost always are glued together. Imagine "SELECT * FROM people WHERE NUM dependents GT 5 AND AVERAGE(dependents.age) GT 12" - the relationship between people and dependents (assuming our model assumes 1:N dependents) is well-understood and we shouldn't need to specify that. We'd really like to be able to go further and have an extensible SQL language, but one where we can declare new keywords and have them fold down into stored procedures (or some other implementation) as appropriate. If we got this right, would we need object databases? There still might be some need, particularly for databases that don't see use that is at all typical of transactional databases (e.g. ones where the dominant use is to send or recieve entire serialised objects).

I imagine having this well done might act as hints to query optimisers, although apart from particularly shoddy databases (like MySQL), I imagine everyone already has a state-of-the-art query optimiser that might not really need hints like this.

I understand (perhaps incorrectly) that domesticated cats and dogs have effectively had portions of their late development turned off, so they remain in a juvenile form for their adult lives, similar to how (perhaps to a lesser extent) humans have portions of our late development turned off and we've lopped off some of the later-life development of apes (Note that I may be either flat out wrong here or so half-right that someone more versed in the literature's face would pucker up like they were eating a lime - I am aware that recapitulation theory is not literally true, but am of the impression that its general thrust has merit, and this is kind of a twist on it anyhow). I wonder if those genes have lost their activation trigger or were excised completely - if they are not typically activated in modern cat, dog, or human, they may have suffered bitrot. Still, it would be interesting to imagine finding a way to activate them (purely out of curiosity), either by bioengineering a fœtus or activating any triggers that might remain in modern adults of the species. Could hormone therapy restart the development cycle of my cats and move them towards being adult desert cats?


  • Lessons about Humanity, from Mars

    As many of you already know, yesterday NASA's MSL-Curiosity rover discovered something, or so we think, in a chemical sample taken on Mars. They…

  • Apish Tongues

    (Apologies for the cross-post with plus, but after I posted this there I realised it's probably more bloglike in character) I have a fascination…

  • Ancient Periscopes

    Three sciency things: Lake Ellsworth, a lake in Antarctica buried deep under the ice, is to have a probe visit it to take samples of the water and…

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 1 comment