nunojob:~ dscape/08$ echo The Black Sheep

Posts tagged ‘xquery’

IBM Data Studio Developer 1.2 Official Release

Foi lançado hoje a nova versão do IBM Data Studio Developer.

Desde que entrei no DB2 Students Group na condição de embaixador tive o privilégio de aprender e mexer com algumas soluções da IBM. Entre o rol de coisas que me agradaram (não vamos falar de coisas tristes, como o IBM_DB adapter para Ruby que na altura estava bastante desactualizado) foram a possibilidade de usar alojar xml nativamente na base de dados. O pureXML com suporte para XQuery foi algo que usei durante o semestre passado em projectos como o Open Source Online Testing System. O facto da LeFevre ter implementado o Mondrian no DB2 também é um ponto a favor para qualquer maluquinho da segurança dos dados. E todos tiveram a oportunidade de ver que implementei o Mondrian no ultimo semestre no âmbito da unidade curricular de criptografia e segurança de sistemas informáticos.

O Data Studio Developer é uma ferramenta para developers que usam DB2. Entre as novidades da nova versão está o suporte para PureQuery e o facto de usar o mesmo tipo de tecnologia de persistencia que a usada no Project Zero. Continuam interessados? Então podem sacar aqui.


Rails::ActiveRecord XQuery && DB2::Mac

Most rails developers use OS-X. Mostly because rails is built-in the latest release (Leopard) and TextMate offers a great IDE to use with Rails. Some could argue that it also works nicely on Windows but I really believe that Rails ain’t done to be used on a Windows Platform. Many articles and interviews with rails creator DHH second this statement. Rails is easy to develop in OS X and deploy in a Linux distro of your choice.

In my most recent screen-cast I explored an interesting technique of taking advantage of rails RESTful design and DB2 pureXML features to easily create a web-service that could query a relational databases with XML support (like DB2). As you must know DB2 Express-C is distributed freely and offers no limitation to home users/small companies. So it would be awesome to expand ActiveRecord to support xml elements, if a schema was provided to the database.

I’m aware that a pure xml database stategy would be a bad approach but there are situations when it simply makes sense. And in those situations one would profit greatly of two things wich are missing.

  • XML Support for ActiveRecord – in construction?
  • DB2 for Mac – will this ever exist?

Antonio Cangiano is creating a plugin that revolves around this concepts, but in a DB2 centered perspective. In my opinion it would be best if the rails plugin worked not only for DB2 but for any database adapter with XML support – as long as such is provided.

Let me give you a sample. Imagine that you have a database model for translating you rails application. It could be something like:


  • ID, int

Imagine that the xml file is

<language isoname="pt-PT">
  <bye>Até a próxima!</bye>

If this makes sense in your application then you could easily do something like register your model to observe (see observer design pattern) the session[‘language’] for changes and, if it’s changed, it would get all the XML for that language – it would fall back to default if such was not available – and create the hash with the values. The problem with this approach – besides making no sense for the internationalization problem! – is that in the observer model you would have to:

Language.find :first

And fetch the whole xml and then process it. If the XML document has 10MB, it would take some time. With XQuery support on ActiveRecord we could simply

Language.find :first, 
  :xcondition => ["//language[@isoname==?]", 

Or, if we simply wanted to say hello in many languages – like flickr in their first page – we could simply

Language.find :first, :xcondition => '//hello'

There are just two problems that prevent rails developers from being able to do this kind of things. And those are the lack of XQuery abilities in ActiveRecord and the fact that Mac developers cannot use DB2.