Sunday, February 19, 2006

Active Ontology for Ruby on Rails

Obie Fernandaz has some ideas for a Ontology based ActiveRecord alternative.

This is a really interesting idea, something I've also been thinking about for a while. One of the tricky things in doing this would be determining what properties a class has. In a RDBMS table you declare that a table (class) has a number of columns (attributes) the mapping to an object model is fairly obvious.

However with OWL and RDF you declare a class and you declare properties, however properties are independant of classes. You can, in RDFS, say that a property has the domain of a specific class, which means that if a Resource has that property it is a member of that class. This is different to RDBMS/OO land where you declare that a class has a property. The difference is subtle but important as it allows you to say things like:
  1. There is a Employee class.
  2. There is a Manager class which is a subclass of Employee.
  3. There is a manages property that has domain Manager.
  4. We can then infer that the manages property also has Employee as its domain since all Managers and Employees. (Note that this the opposite of OO where properties and inherited down the class heirarchy).
  5. We can then create an instance of Employee. It is valid to give that Employee a manages property pointing at another Employee instance. We can then infer that the Employee is also a manager.
When you want to map this to OO though, which class gets the manages property? It is correct to give it Employee since we infered that Employee is a valid domain for manages. Except any Employee who manages someone is a Manager too.

This is one of the tricky things that will arise out of the differences between Ontologies and OO. A couple of the others are multiple inheritence and multiple class membership.

Most of these issues could be worked out after the initial functionality is there, but it should interesting to see how they are tackled.

Update: Man I really need to look at dates before I respond to blogs.

Technorati: ,

Saturday, February 18, 2006

RDF Schema Generator

I've release my first Rails generator on Ruby Forge. RDF Schema Generator builds a Ruby Module from an RDFS file. The module contains constants for each of the properties and classes in the Schema. If you are using Rails to build RDF based applications you might find it useful.

Install it using gem install rdf_schema_generator.

Once it is installed you can run
ruby script/generate rdf_schema <prefix> <rdfs_url>
and a class called will be generated in the lib directory containing a module with all the classes and properties for the RDFS file retreived from <rdfs_url>.

Enjoy!


Tags: Ruby Rails RDF

First Post

Well, this is my first ever blog post.

By way of introduction - my name is Sean Geoghegan, I'm a geek, I work as a computer programmer. I'm currently into Ruby on Rails and really want to write a Rails based web application in the guise of flickr or 43things that becomes hugely popular, I just need an idea, if you have one post it in a comment.