Get Started with SQL for Cloud Computing: Microsoft SQL Data Services (cont'd)

Querying Your Data

SDS uses a simple text-based query language, based on the LINQ pattern for C#.

You can scope queries to either an individual authority or to an individual container:

  • You can query an authority for the containers within it that match a specified condition.
  • You can query a container for the entities within it that match a specified condition.

An SDS query takes the following format:

from e in entities [where condition] select e

Note that the from e in entities format applies regardless of whether you are retrieving containers or entities. In SDS, authorities, containers, and entities are all types of flexible entities.

To submit your query, you must specify the scope and then supply the query expression. For example, to query for containers by using the REST protocol, you simply append your query to the authority URI as a query string:

https://london.data.beta.mssds.com/v1/?='from e in entities…'

Similarly, to query for entities, you append your query to the container URI:

https://london.data.beta.mssds.com/v1/<container-id>/?='from e in entities…'

You can use comparison operators and Boolean operators to add conditions to your queries. The current beta version of SDS supports the following operators:

Comparison operators

>     (greater than)
>=   (greater than or equal to)
<     (less than)
<=   (less than or equal to)
==   (equal to)
!=    (not equal to)
Boolean operators
&&  (logical AND)
||     (logical OR)
!      (logical NOT)

Table 5: Supported comparison and Boolean operators

For example, to retrieve all the entities within a container that have a City property equal to Seattle and the State property equal to WA, you would structure your query as follows:

from e in entities where e["City"] == "Seattle" && e["State"] == "WA" select e               

To query metadata properties, you use the dot notation instead. For example:

from e in entities where e.Id == "exampleID" select e

Simple join operations are also supported. The current query capabilities of SDS are a first step, and will be extended over time.

Securing Your Data

SDS provides security at the account and authority levels. Accounts are secured by a Windows Live ID. Each authority is secured by a single account name and password combination that grants read/write access. Soon SDS will also have integration with Microsoft Windows® .NET Access Control Services for richer authentication and more granular levels of authorization.

BLOB Support

We asked architects and developers which features they would most like to see included in a flexible data infrastructure, and BLOB support was at the top of the list. BLOB support enables you to store videos, images, and other files as binary-encoded data, making SDS a feasible data platform for photo or video clip libraries, music players, document stores, and any number of other innovative applications. The current beta version of SDS supports BLOBs of up to 100MB, and upcoming releases will support larger BLOBs.

In SDS, BLOBs are defined in a similar way to other entities. Each BLOB entity has Id, Version, and Kind metadata properties, although currently the Kind property has a fixed value of "Entity". However, BLOB entities have an additional metadata property named Content. The Content property has three attributes that you use to record information on how the BLOB should be handled.

Content attribute

Purpose

content-type

Specifies the MIME type of the BLOB content.

content-length

Specifies the size of the BLOB.

content-disposition

Optionally specifies how the client should handle the BLOB. For example, Web browsers use the content-disposition header to suggest a filename when a user downloads a file.

Table 6: Attributes of the Content metadata property

Currently, you must use the REST interface to work with BLOB data in SDS.

Support for ADO.NET Data Services

The ADO.NET Data Services framework is a set of patterns and libraries that you can use to create and consume Web-based data services. The framework was conceived to support two key trends.

First, Web applications increasingly rely on client-side technologies such as Microsoft Silverlight and Flash to drive presentation and interactivity. The traditional post-back model used to bind server-side data to client-side presentation is increasingly inadequate for these rich interactive applications. ADO.NET Data Services enables the Web browser to retrieve and consume data directly from an Internet-facing data source.

Second, Web-based mashup applications that aggregate data from many disparate sources are becoming increasingly commonplace. ADO.NET Data Services can help you to both provide and consume data for this type of application.

SDS will provide an ADO.NET Data Services-compatible interface. This interface is now available in preview form. You can direct your client software to use this interface in the same way you would use any Web service compliant with ADO.NET Data Services.

Conclusion

In this paper, we have introduced SDS and described its key capabilities and benefits. SDS is a cloud-deployed database service that offers developer agility, application flexibility, and virtually unlimited scalability, with a flexible, cost-effective delivery model. The robust underlying architecture provides reliability, high availability, and security, while support for the most prevalent Internet communication protocols ensures ease of deployment and use. We have examined some scenarios where SDS can offer real business value to customers, such as data hub solutions and archival and compliance systems. We've also taken a look "under the hood" at the architectural and programming models that provide the core functionality of SDS.

For more information, please visit:

* This whitepaper is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED, OR STATUTORY, AS TO THE INFORMATION IN THIS DOCUMENT.


Previous Page: Typical Scenarios  
Page 1: Getting StartedPage 3: Querying Your Data
Page 2: Typical Scenarios 
Bytes by MSDN
Listen or watch influential community and Microsoft developers talk on topics they are passionate about.
Let's talk Windows Phone 7! Join our latest series of Bytes by MSDN as Tim Huckaby kicks it off with an interview with Brandon Watson, Director of Developer Experience for Windows Phone 7 at Microsoft.
Jim O'Neil explains how cloud computing can be a startup's best friend.
Cliff Simpkins and Brian Gorbett discuss the Windows Phone 7 developer experience and how they will make developers rich.
Whurley disucsses why developing on the Windows Phone 7 platform is enjoyable.
Chris Maliwat talks about how Internet Explorer 9 can improve site performance.
How Do I Videos