Thursday, November 20, 2008

Eloquera applications

Eloquera is being actively developed. Our team is working on adding new features and extending the current functionality. The current product is however, already quite suitable for use in some applications as the data storage backend. For example, the content management system of the 
www.eloquera.com website uses Eloquera to store all its data.

Eloquera has many unique features, but the main reason to use it, is the way it enhances and speeds database development. It radically reduces the complexity of designing, implementing and supporting the database and its engine. The developer is freed to focus on the primary task of developing the application using object-oriented programming techniques.

Below are a few examples of how Eloquera has been used in different web-oriented projects, and what impact it has had on the performance of the developers.


Web-based content management system

Modern CMSes are the core of web publishing. Almost any CMS nowadays stores its content and settings in a relational database. That seems a very natural choice as such systems store massive amounts of the text data. However, every web developer knows that CMS is not just about text. 

Content management system stores the links between documents, the different sections of the document, and each section has its own properties and ways to display data.

For the sake of simplicity here we will consider only a very simple example, looking at the functionality that covers the headings and the pre-formatted items (the base for things like quotes, examples, insets).

All programming starts with the class definitions, and here is a very basic code. You can draw a sketch for such a simple system in just a minute or so.


Basic definitions for the content management system.
public class DocoItem
{
    public string Text { get; set; }
    public string ParentId { get; set; }
    public int DocoOrder { get; set; }
}
 
public class DocoHeader : DocoItem
{
    public DocoHeaderType HeaderType { get; set; }
}
 
public enum DocoHeaderType : int
{
    PageTitle = 1,
    SectionHeader = 2,
    Navigation = 3
}
 
public class DocoPreformattedItem : DocoItem
{
    public string OriginalText { get; set; }
} 

And now the database part.

Eloquera design

Eh, what design? Can't a computer create a design that is most suitable for it? Sure, it can. These monotonic tasks are what the computers are good at!

Relational table design.

Here we have 3 tables (in fact, we need 4, one for the header type, but let's keep things simple), and 2 relationships between them.














Eloquera query

Getting data is the most used operation in the database world. And what is the most popular languange for getting data? Of course, good old SQL. Here it is.

Run query to get data.

var docos = 
  db.ExecuteQuery(
    "SELECT DocoItem WHERE ParentId = " + 
    Quote(docoName) + 
    " ORDER BY DocoOrder"
  );

Yes, it is just one line. We separated them for your convinience.

Now let's see what the relational databases have to offer.


Relational database query


First, we create a stored procedure that gets the data from the database.

CREATE PROCEDURE GetDoco(
@DocoName NVARCHAR(64)
)
AS
BEGIN
    -- These are text lines
    SELECT 
        d.DocoOrder, 
        d.Text
    FROM
        DocoItems d
    WHERE
        d.DocoName = @DocoName
        AND d.DocoType = 0
        
    -- Here comes the second recordset
    -- with the headers.
 
    SELECT 
        d.DocoOrder, 
        d.Text,
        dh.HeaderType,
        dh.HeaderLevel
    FROM
        DocoItems d 
          INNER JOIN 
        Headers dh
          ON 
        d.DocoItemID = dh.ID
    WHERE
        d.DocoName = @DocoName
        AND d.DocoType = 1
    
    -- And the third recordset
    -- with the pre-formatted items.
    SELECT 
        d.DocoOrder, 
        d.Text,
        dp.IsOriginal,
        dp.OriginalText
    FROM
        DocoItems d 
          INNER JOIN 
        DocoPreformattedItems dp
          ON 
        d.DocoItemID = dp.ID
    WHERE
        d.DocoName = @DocoName
        AND d.DocoType = 2
END      
After that there must be code to get this stored procedure running and to collect the results. It is no shorter than the example above, and it is not really interesting. Still want to see it? Contact us as www.eloquera.com/contact and we will send you that code.
It is really good for insomnia!