Burning SQL bras

RDF makes me feel so liberated now that I've actually got it all up and running! Storing data in a freeform RDF graph is so easy when you don't have to worry about setting up tables or writing queries or anything. Add an arc, remove an arc. It's that simple.

Liberation is not enough of an incentive on its own, perhaps, but the fact that your web applications are trivially Semantic Web-ready when using an RDF database means that this is definitely the way I will be writing web applications from now on! (Subject to caveats about speed and optimisation and legacy code and pure appropriateness).

In particular, I've been able to write a single, easy-to-use class that displays a configurable form, pre-filled from the model, and saves changes back to the model on submit. Code for this looks like this:


$form=new RDFForm($model, $me);

$form->setAction('profile.php?view=basics');

$form->addMultipleFieldMapping(vocab('foaf:name'), new StringLiteralProperty(_('Name')));

$form->addFieldMapping(vocab('foaf:title'), new StringLiteralProperty(_('Title'), 4));

$form->addFieldMapping(vocab('foaf:givenName'), new StringLiteralProperty(_('First Name')));

$form->addFieldMapping(vocab('foaf:surname'), new StringLiteralProperty(_('Surname')));

$form->addMultipleFieldMapping(vocab('foaf:nick'), new StringLiteralProperty(_('Nickname')));

$gender=new LiteralEnumProperty(_('Gender'));

$gender->addOption('male', _('Male'));

$gender->addOption('female', _('Female'));

$form->addFieldMapping(vocab('foaf:gender'), $gender);

if (isset($_POST['save']))

{ $form->updateModel(); }

$form->render();

Of course, this is possible with relational databases too given enough layers of wrappers, but this approach makes it trivial to

implement new fields and new field types. Here is a screenshot of how this appears on the page.

RDF Form Screenshot

Comments

Comments powered by Disqus