Tuesday, March 15, 2011

Database Schema for Machine Tags?

Machine tags are more precise tags: http://www.flickr.com/groups/api/discuss/72157594497877875. They allow a user to basically tag anything as an object in the format object:property=value

Any tips on a rdbms schema that implements this? Just wondering if anyone has already dabbled with this. I imagine the schema is quite similar to implementing rdf triples in a rdbms

From stackoverflow
  • Unless you start trying to get into some optimisation, you'll end up with a table with Object, Property and Value columns Each record representing a single triple.

    Anything more complicated, I'd suggested looking the documentation for Jena, Sesame, etc.

  • I ended up implementing this schema

  • If you want to continue with the RDBMS approach then the following schema might work

    CREATE TABLE predicates (
      id INT PRIMARY KEY,
      namespace VARCHAR(255),
      localName VARCHAR(255)
    ) 
    
    CREATE TABLE values (
      subject INT,
      predicate INT,
      value VARCHAR(255)
    )
    

    The table predicates holds the tag definitions and values the values.

    But Mat is also right. If there are more requirements then it's probably feasible to use an RDF engine with SQL persistence support.

0 comments:

Post a Comment