SQL and XML are not that different

2 minute read

About a year ago, I had presented my 8th semester presentation on Xen, now called C Omega. It is a language that combines SQL, XML and OOP into one tight language. The paper that proposed this language was named Programming with Circles, Triangles and Rectangles. The circle represents the encapsulation behavior of objects and OOP, the triangle represents the tree structure of the XML and the rectangle represents the tabular structure of databases.

Video of Anders Hejlsberg talking about C# 3.0

I recently came across Anders Hejlsberg's interview on Channel 9 regarding programming data in C# 3.0 and it looks like C-Omega is going to be 'merged' into 3.0. Its amazing that MS has taken this concept (which seemed totally radical to me when I first read about it) to production quality and is actually going to make this a core part of their platform.

Let us consider an example of using C-Omega. Suppose you want to handle books in a program used to manage libraries. Then you could write a book class using C-Omega as

[code] public class book { sequence {

string title;
choice {
  sequence{ editor editor; }+;
  sequence{ author author; }+;
string publisher;
int price;

} attribute int year; } [/code]

The cool part is that the above same class can be used to store the data either as XML or in a relational database. You can also instantiate an object using XML syntax:

[code] book b = A Byte of Python

<first>Swaroop</first><last>C H</last>

www.byteofpython.info 250 ; [/code]

Note that this syntax is still static typing. Needless to say, the C-Omega compiler must be one heck of a monster.

The Python connection is that the C-Omega-ish method of access will probably be included into IronPython at some stage. Even if that doesn't happen, we already have Pythonic ways of doing XML as pointed out long ago by wspace.

If you have ever written a program that uses databases, I highly recommend reading the Circles, Triangles and Rectangles paper. It just might change the way you think about databases and SQL, or even XML for that matter.

You can also download that old presentation of mine on Xen.


What is SQL? says:

SQL and XML may be similar as far as retreiving data is concerned, but for inserting data SQL is much more powerful and easy to work with. And just try updating data stored in XML!

If one wants to move away from large DB engines such as MySQL I highly recommend SQLite.