RSDP: A Really Simple Proposal
Pages: 1, 2
A Really Simple Proposal
As specifications go, RSDP is about as simple as it gets; almost simple enough to squeeze onto a cocktail napkin.
Incoming Query
An RSDP server should expect to receive either an XML-RPC (machine-machine) or HTTP/CGI (human-machine) query. The server will listen on two user defined ports, one for HTTP, one for HTTPS.
If the client opens the base URL for the server, the server responds by serving an HTML form that allows the user to interact with the server manually. This is provided so that users can interact with the server manually. It need not be an especially pretty interface, just sufficient so that developers can submit test queries that mirror XML-RPC queries. This will be helpful for troubleshooting purposes.
If the client submits an XML-RPC query, the server should present a single XML-RPC method, rsdp(), which is invoked as follows:
rdsp(dbname, username, password, querytype, query, strict, outputformat)
rsdp("books","brian","password","sql","SELECT * FROM books WHERE
author = 'Brian McConnell' ORDER BY pubdate;'",false,"xml")
NOTE: this instance of rsdp() invokes a SQL query, but the
querytype param allows other query languages such as XQuery
to be used as well.
The RSDP server then invokes the query expression, after first validating the user. The server is responsible for implementing security policies (for example, access control lists, IP filtering, etc.) internally.
Result Set
If the client is interacting with the server via the HTML form interface, the server will present records within tables, perhaps with a hyperlink to display the same recordset in XML.
If the client is interacting with the server via XML-RPC, the server will reply by either returning an error code, or by returning an XML recordset, as shown in the example below (data types are omitted for brevity). If the optional strict parameter is true, the server returns strictly typed XML, using the basic data types defined in the XML spec. If false or omitted, the server returns loosely typed XML and assumes the client application will perform any necessary data type conversions. The outputformat parameter allows the client to request other formats besides XML, such as CSV, HTML, and so on.
<recordset>
<count>X</count>
<record>
<recid>1234</recid>
<firstname>John</firstname>
<lastname>Doe</lastname>
</record>
<record>
....
</record>
</recordset>
Implementing RSDP should require a minimal effort on the part of database vendors. If vendors are slow to do this, developers can build scripts to provide this functionality in the interim. Since it is trivial to build XML-RPC web services in languages like PHP, developers need not wait for vendors to ship direct support for RSDP and can build their own solutions. In the long run, it will be best if vendors support something like this directly, as they will be able to optimize the interface for performance, as well as to implement security features within the database engine (rather than rely on an external script to intercept malicious SQL commands).
Class Libraries and Wrapper Functions
Using RSDP in client-side applications will generally be quite straightforward, since most languages now support XML-RPC.
Developers can further simplify the interface by writing small class libraries or wrapper functions that make the XML-RPC interface look like a conventional database API.
For example, one might create a rsdp class in Python that exposes a set of methods such as:
rsdp.execute(): Execute SQL query.rsdp.forward(): Skip forward one record.rsdp.back(): Skip back one record.rsdp.first(): Jump to first item in recordset.rsdp.last(): Jump to last item in recordset.
This approach will provide developers with something that looks and behaves as expected, while also providing an additional layer of idiot-proofing. In fact, the class will just submit a query, store the results, and provide the same type of cursor methods found in existing database APIs. This won't improve performance, but it will make the interface to RSDP consistent with conventional APIs. This will also ease the transition to vendor-specific interfaces if a project outgrows RSDP.
Summary
RDSP, or whatever it ends up being called, will not replace current database access protocols, but it will have an important role to play in rapid application development, and in distributed applications.
As I mentioned earlier, databases are easy enough to work with, after you've installed the DB server and necessary middleware to communicate with it. The problem with currently available tools is that it is difficult to build distributable packages that use client/server databases. While it is certainly possible to build packages that automatically install and configure the necessary components, doing so requires a lot of time and effort that could otherwise be spent refining the application itself.
While it will not solve SQL compatibility issues between vendors, an interface like RDSP will eliminate the need for an application to be tightly coupled with database middleware (for example, ODBC drivers in Windows, a MySQL package for Perl, etc). This will save time for developers, who will not have to spend so much time on installation scripts, and for users, who will not have to fight with as many database configuration issues.
RSDP will also enable ASPs to host database services, much as companies currently host websites, blogs, and the like. While it may not scale well enough for enterprise applications, this will certainly be viable for most small- and mid-sized projects. Moreover, if the interface proves popular, I think it is likely that people will find workarounds to the performance issues that are likely to arise (for example, by using HTTP load balancing to spread workload around among the servers answering read-only queries).
Next Steps and Neat Tricks
What is the next step? RDSP front ends can be built with or without vendor participation. To further this end, I have created a wiki where people can post documentation and pointers to RSDP implementations for various database engines. If this takes off, hopefully vendors will follow up by embedding RDSP-like support in their systems.
Apart from simplifying database access, RSDP has the potential to be the equivalent of RSS on steroids. RSDP calls embedded within web pages could link to many different databases to merge dynamic content into web pages.
For example, imagine a website that covers upcoming events. RSDP would make it easy to display event information. One would simply embed a statement like:
rsdprss("events","guest","password","sql","SELECT * FROM calendar
WHERE startdate >= #20050402# AND startdate <= #20050502#
AND category = 'movies' ORDER BY startdate;")
The web server queries the database server and imports the recordset as an RSS feed. Thus, people would be able to create websites that pull content in using specific search criteria from many different sources. This is just a simple example of how you might do this. Once you make databases more readily accessible, there are all sorts of potential applications.
More Information
For more information, documentation, and source code for RSDP client and server implementations, visit the RSDP Wiki at rsdp.editme.com.Brian McConnell is an inventor, author, and serial telecom entrepreneur. He has founded three telecom startups since moving to California. The most recent, Open Communication Systems, designs cutting-edge telecom applications based on open standards telephony technology.
Return to the O'Reilly Network.
Showing messages 1 through 7 of 7.
-
Field names and XML tags
2005-05-08 03:42:00 yitzgale [View]
-
Why not REST instead of XML-RPC
2005-04-14 00:12:52 rinie [View]
Would be nicer?
Using PHP AdoDB in between gives you already more SQL portability
-
Chicken Vs Egg - Transport and Application Layer Protocols
2005-04-11 22:34:08 Brian McConnell |
[View]
From the author... It didn't occur to me to make this point prior to deadline...
Think about SQL as something analogous to an application layer protocol such as POP3, which rides upon TCP, a transport layer protocol. (HTML over HTTP is another good analogy).
Usually what we see is that application layer protocols are developed after transport protocols, as was the case with POP3, IMAP, SIP, etc.
What's interesting about SQL is that it provides a reasonably platform neutral way of expressing queries, yet it does not have an Internet friendly transport protocol that it rides upon.
Imagine what the web would be like if it operated like today's database systems. We'd have a platform neutral markup language (HTML ... analogous to SQL), but each web server would have a different client/server transport protocol. I think you can see where this is heading, to lots of headaches, and that's basically where we are at today with respect to databases.
This really isn't such a radical proposal when you think of it in this context. The difficult job of building a reasonably vendor neutral query language was done a long time ago. All we need now is a simple HTTP oriented interface to complement proprietary client/server interfaces (e.g. ODBC).
The transport piece of the puzzle is actually much easier to deal with than the query language, as this is a simple two-step transaction: 1) XML-RPC method call going into the DB server with a consistent parameter list (one to the parameters being a SQL query), 2) XML recordset going out to the client. Piece of cake compared to implementing an email protocol like IMAP4. -
Chicken Vs Egg - Transport and Application Layer Protocols
2005-04-12 07:21:29 Jonathan Gennick |
[View]
Quoting:
"What's interesting about SQL is that it provides a reasonably platform neutral way of expressing queries, yet it does not have an Internet friendly transport protocol that it rides upon."
I like this way of thinking about the problem. Why not have a common, Internet-friendly transport protocol for SQL? Maybe that transport doesn't have to be XML-based, but a common-transport of some type would seem to me to be a good thing.
-
Database as Web Service
2005-04-11 22:22:38 matthew.chiu [View]
Interesting idea.. I might be thinking of something different: why not use XML for the query language so you can hide the implementation details of the database from the user. It would be a quick way of sharing a database as a web service without creating an API for it.
-
Check out example in online Python Cookbook.
2005-04-11 17:56:16 GrahamDumpleton [View]
XML-RPC interfaces to database services have been described before. See the online Python cookbook for an example.
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81613 -
Check out example in online Python Cookbook.
2005-04-11 19:01:09 Brian McConnell |
[View]
This is true. However, the point of the article is to promote the creation of a simple and consistent XML-RPC or similar interface for use in querying databases.
If every database server recognized a simple, albeit limited, RPC call, this would eliminate the need to struggle with database middleware, vendor specific libraries, etc in many situations.
While it's true that many of the individual pieces needed to do this are out there, and have been for some time, there isn't the database equivalent of RSS that provides a reasonably vendor neutral interface. Based on my recent experience, such a thing is badly needed, as I spent probably 80% of my time trying to figure out how to get a DB specific library to work correctly in different installation scenarios versus debugging the application itself.
Stated simply, SQL provides a reasonably vendor neutral way to express queries. What's needed now is an Internet friendly way to deliver queries to DB servers, without getting bogged down in unnecessarily bloated middleware, external libraries, etc.










you need to specify exactly how to translate
between general SQL field names and valid
XML tags.