Getting started

After receiving the confirmation you’ll be able to access the services.

Adding the service reference

In order to use the SSDS instance, we need to add a reference to the SOAP service. The URL is http://data.beta.mssds.com/soap/v1?wsdl. Remember that this is a beta instance, so the URL can be changed in any moment.

Creating entities

SSDS has a defined structure: authorities, containers and entities. Then, we need to create those entities in order to use the service.

Creating the proxy

When creating the proxy, you should only submit the client credentials.

I’ve been researching one of Microsoft’s newest services: SQL Server Data Services (aka SSDS). In this post I will present my first impressions about this technology.

Motivation

The motivation of this service is to provide a scalable data storage and query processor utility "on the cloud". Using this approach, the costs of infrastructure and support decreases, since that responsibility relies on Microsoft and not in the software provider.

Besides, more and more new Web applications need to save less complex data, with a high service level agreement (SLA).

Implementation

SSDS is built on the SQL Server technology, using the SOAP and REST communication protocols. Some of the features are:

No schema. Since the data model is flexible, we now can have heterogeneous entities (serialization becomes more complex).

Pay-as-you-grow model. The space used can grow as you need it.

SLA covering high availability, performance and redundancy.

Easy to develop. In order to use the data we only need to call the appropriate Web Service.

Customers are the organizations that are using the SSDS. Customers have many Accounts.

Accounts are the billing entities. An account has authorities assigned.

Authorities are the ones that organize the data containers. It defines the location and security policies of its containers.

Containers are the scope for the entity storage and query. For example, each employee may have a container with its personal data.

Entities are the storage unit of SSDS, for example the employee’s education information.

Conclusion

I think that this service has a lot of potential. With the growth of Web2.0 and social applications, we need a way of deploying small applications with a reliable data access. Obviously is very expensive to deploy and maintain a data base server, so having that service on-the-cloud is a very interesting alternative.

From the technical point of view, the no-schema structure is very interesting. Still, I guess that it can have a negative impact in the serialization process.

On the other hand, this service is still in working process, so we’ll be awaiting for new features to come.

Most developers must agree that parsing a string in order to build the data structure that it represents is a very tedious task. As a matter of fact is horrible. There’s a lot of code, lots of border cases, lots of bugs; and the list continues. Personally, I’ve spent lots of programming hours dealing with these issues.

Gladly, there’s a field of research in the Computer Science that focuses of parsers and syntax analyzers: the Languages Theory. One of its fields of study tries to find formal, correct and efficient ways to parse strings, and we can use that knowledge (and stop reinventing the wheel).

ANTLR

ANTLR is a tool that generates recognizers for grammatical descriptions in C#, Java and other programming languages. It also offers a GUI to create and debug those grammars. All we need to do is program the data structures and define the desired grammar (don’t worry if you’ve never heard about this, after reading an example you’ll see that is not that difficult).

Example scenario

Suppose that we want to implement an SQL parser: just parsing the query and generating the correct data structure. Let’s keep it simple; focus on a SELECT [fields] FROM [tables] query and don’t worry about the consistency of the queries. We only want to parse the input string.Â

Data structure

After analyzing the scenario we can infer that we’ll have a SelectQuery that contains Fields and Tables. The class diagram should be:

Grammar

Now let’s take a look at how the grammar is created. Remember that ANTLR is a code generation tool, so we will define the grammar and also some configuration options. A grammar is the formal description of a language. In our case, the language will be all the strings that start with SELECT, then a list of Fields, then the FROM keyword and finally the list of queries. The syntax is really simple, we just define the structure of the correct inputs and the code that we need to add. This grammar is defines like:

Line 20 specifies that the result from this structure is going to be a SelectQuery instance.

Line 21 defines the syntax of the structure.

Line 22 is the specific code that we need to add in order to create the result instance. In this case we need to create the SelectQuery object. This code is written between curly brackets.

Lines 24 to 26 define how the tables should be written. Notice that we can use the regular expressions wildcards like ‘*’ and ‘+’. Also the @init code block. There we can write the initialization code for the data structure.

Then we select the Generate option and add the code to the project. Remember that we also need to add a reference to the runtime library, available at the ANTLR site.

Â

Using the parser

Now all we have to do is use the generated classes (the lexer and the parser).

And that’s it. Now query is the data structure obtained from the input string. Later we can specify how we want to deal with the errors in the input (by defaults, it writes them in the output console).