- From: Austin William Wright <aaa@bzfx.net>
- Date: Fri, 18 Oct 2013 13:54:03 -0700
- To: "public-rdfjs@w3.org" <public-rdfjs@w3.org>
- Message-ID: <CANkuk-VdtZ7Q7OjhUadP_JW0aeG=xq+ZyVPm-_JDzUMYrHns0Q@mail.gmail.com>
I'd like to see a database API that effectively brings prepared statements and indexes to RDF databases. It should have the following features: * An RDF database for use in the Web browser or server-side * Features to synchronize data between sources (especially between central server and Web browsers) * Prepared statements with indexed responses, to skip subgraph matching at query time for fast responses (subgraph matching is O(n!) worst-case -- yikes!) * Transactions support, since a single query involves operations on many atomic units of data that need to be coherent at all times * Uses the existing RDF Interfaces APIs where possible * Support for SPARQL-style named graphs Opening the database might look very similar to IndexedDB. Then, you can create a prepared statement/index. It might use SPARQL: var store = db.createQuery("books", new IGSPARQLQuery("SELECT ?title WHERE { ?book <http://purl.org/dc/elements/1.1/title> ?title . }")); store.createIndex("book-title", ["book UNORDERED","author DESC"]); Or, defining the index and query might be done together in the ORDER BY clause, so you can use ASC and DESC as appropriate. We might also define an "unordered" type of index to allow usage of better indexes that can't be iterated over in part, like hash tables. Then, when you want to query the database: var tx = db.transaction("readonly"); var rs = query.execute("book-title", {book: "http://example.com/book/1"}); /* Do stuff with rs */ With just the standard SPO/POS/OSP three indexes, this query can be executed no matter what variable is defined. However for more complex subgraph patterns, there may not be a registered index, in which case the API could either throw an error or attempt standard subgraph matching. I'd like to promote using the indexes and avoid running unindexed queries, a problem that plagues SQL-based Web applications. Modifying data would have its own API (similar to RDF Interfaces, and using RDF Interfaces where possible), not necessarily using a query language: tx.add(new Triple("http://example.com/book/1", " http://purl.org/dc/elements/1.1/title", "http://example.com/author/45")); However, there's no reason you couldn't use a prepared DELETE/INSERT query: var tx = db.transaction("readwrite"); tx.execute("book-insert", {book: "http://example.com/book/1", " http://example.com/author/45"}); And since this is RDF Interfaces, there's mechanisms to use CURIEs, for your convenience. This API isn't fleshed out yet, of course, but I'm curious: Is something we're willing to look at? What ideas or features people are looking for? Austin Wright.
Received on Friday, 18 October 2013 20:54:30 UTC