Tuesday, January 10, 2012

Relational DB and Objects


Strange observation.

DB's mature over time and adapt to new requirements much easier than code. Code breaks from release to release and after some time needs major changes to keep in shape.

Relational DBs are more Zen compatible - A is A and A is not A. Code is usually not so flexible. More strangely, relational db's are less flexible (schema, everything is table) and ends up being more flexible whereas code is flexible (extend, copy-paste, interfaces, override) and ends up being inflexible.

Wonder, if we could associate code (C, Java, PHP) with tables/columns or joins and write our web applications in SQL.  Immediately all the hashmaps and arrays become moot. No for/while loops just select/where.  It becomes so much easier to create as many views as you like which are consistent by writing new SQL queries.  If queries can be named, they can be used as first level objects for creating higher level queries.  Empty tables that only have code associated with them but no data, can be used for providing all the decoration or access control or mappings.

I haven't seen something like this, but I do think that it is very much possible to build. With all the ORM tools and frameworks we are almost at the point where talking to DB is almost automated. I guess all I want to say is that SQL is probably a good framework for not just managing data, but also code. Lets give it a shot.

No comments:

Post a Comment