I was reading today on SQLServerCentral.com about SQL Server’s XQuery capabilities. I was quite fascinated. Microsoft has seemed somewhat slow on the XML uptake, so including XQuery in SQL Server 2005 was somewhat of a shock.
However, I was struck with an idea after reading the article. This type of functionality puts SQL Server on a level with eXist as an XML database server. By this I mean that lots of opportunities now open up to serving XML to a client application instead of using a lot of database resources. (For those unfamiliar with eXist, it has built in REST, SOAP, and WebDav services available out of the box; SQL Server has SOAP through the CREATE ENDPOINT statement.)
This led me to thinking again about the MVC design pattern and an ideal way in which to set up that pattern. I came to the conclusion that there are macro- and micro- versions of the pattern. Most of the time MVC is mentioned, it is in the context of keeping everything relatively within one language (e.g. ASP.NET MVC, Ruby on Rails or XForms). That would be an example of a micro-MVC pattern.
A macro-MVC pattern could be the separation of XML documents (models), Javascript (controller), and HTML + CSS + XSLT (views) as found in the freja framework. Most of those components are often seen in web development but not often considered when discussing MVC. Typically, only the language that produces the XML would be considered worthy of an MVC designation, if it also produced the other pieces.
Now to the point: one might use SQL Server to produce the XML models, C# classes to perform the duties of the controller (i.e. parsing URLs, XML, etc. and feeding the views), and either XForms or the HTML + CSS + XSLT trio for views. The best thing about this combination over using views with eXist is that SQL Server still stores its data in a relational database. A DBA could create the stored procedures necessary to create the XML documents and update the underlying tables, thereby keeping all of the business logic in one domain and truly separating models from controllers and views.
I’m going to make an attempt at using this methodology soon, probably with XForms as the view layer. I will be sure to post my experiences when I get further along.