Friday, August 19, 2005

How I'm Going To Make The Semantic Web

i need to ramble
why don't we have the semantic web; it's good and stuff
problem: switching from mysql/postgres/etc
to thinking in triplestores built ontop of those
Just Too Hard, technology isn't there yet, etc
DAO code, like PEAR::DB_DataObject lets you work with mysql/etc really easily
you type into the command line and it produces templates for all of your classes
to do queries, you go

DataObject::factory('tablename');
$foo = DataObject::factory('tablename'); even
$foo->get('1'); //record id #1
$foo->tablefieldName = "blah";
$foo->save();
if you need to do anything funky
you extend the dataobject
and you don't have to think

RDF: people don't get it
too hard
no benefits
what's the point of producing it from my database?
i'll just roll my own web service API
and people can use that.

Different web services make life hell
because you have to translate between external API and internal API
it's pretty good compared to what it was
but it's still a bit of effort
*especially* if you have to code the SDK from scratch

Web services have their place
but they should be for doing things like calculateHowCoolIam()
rather than for data access


Now: Migrating between two databases
RDF is really good here
*if* you can map your data to common, well established ontologies
ie, your user profiles in FOAF
your project data in DOAP
whatever

so, why not make semantic web services
which are built up from dataobjects.

you type make classes
it gets a local representaiton of you DB and makes all of the objects

you type make more classes: http://www.foaf.com/foaf.rdf
and it gets foaf.rdf's RDFS [schema/ontology]
parses that
and produces more classes


when you work with your RDFdataobject
you can translate to and from RDF with no fuss
all your coding consists of is stapling
title = dc:title
id = rdfs:nodeID
image = foaf:depiction

in some config file somewhere

Intended use:

$foo = RDFDataObject::factory('tbl_users');
$foo->get('1');
print $foo->toRDF();
Or as a parser:

$rdf = "A WHOLE LOT OF RDF FROM SOMEWHERE ON THE WEB";
$foo = RDFDataObject::Parse('tbl_users', $rdf);

The side benefits of this?
  • You get a webservice layer built right atop your database, RESTfully.
  • Data Interchange. If I want to translate your user profiles to my user profiles, the RDFDataObjects strive for the best case, minimal loss of information. Maybe I don't and have no intention of storing birthdates, so the dataobject just ignores that.
  • It's not a triplestore, but it's not an ordinary database anymore. It's lightweight automagical syndication, replication, and webservices all grafted together.

I've scribbled out a few vague sketchings of an RDFS parser that pumps out PHP code, heckle me with blog comments if I don't get on with it by the end of the month.

No comments: