SQL Data Services Adventure – Day 3

Saturday, 29 November 2008 08:23 by james

In the last post I talked about the structure of how SDS stores data. An Authority is geo-located and stores the containers. Multiple Containers can be stored in an Authority and each Container can hold multiple Entities.

I’m tired and need some REST, but after I wash with some SOAP

SQL Data Services support both REST (Representational State Transfer) and SOAP (Simple Object Access Protocol) interfaces which allows the use of practically any language and web development tools. For the rest of this series I will be focusing on interacting with SDS via REST.

Four kinds of URIs (Uniform Resource Identifier) are used when programming SDS with REST. Each of these URIs sets a scope for a set of operation to be performed. Each URI should look familiar by now:

Service – Used when creating and querying authorities

Authority – Used for creating and querying containers and to retrieve metadata regarding particular authorities

Container – Used for creating and querying entities, retrieving metadata about a particular container and for deleting a specific container

Entity – Used when retrieving, updating and deleting specific entities

Figuring out the pieces

Service URI

https://data.database.windows.net/v1/

In the URI above, data.database.windows.net refers to the Service while v1 references the version of the service.

A query can be appended to the end of the URI to query for Authorities which have been created, like this

https://data.database.windows.net/v1/q=’<some really cool query>’

Authority URI

To query against a particular Authority,  you prepend the URI with the name of the Authority you want to work with. For example:

https://duringlunch-01.data.database.windows.net/v1/

returns a single entity which contains metadata about the referenced Authority. The entity returned is XML like this:

   1: <s:Authority 
   2:     xmlns:s="http://schemas.microsoft.com/sitka/2008/03/" 
   3:     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
   4:     xmlns:x="http://www.w3.org/2001/XMLSchema">
   5:       <s:Id>PizzaRecipes</s:Id>
   6:       <s:Version>2234</s:Version>
   7: </s:Authority>

As the same with Service URIs you can also append a query to an Authority URI to query against all the Containers in the Authority

https://duringlunch-01.data.database.windows.net/v1/q=’<a query to find containers>’

Container URI

The Container URI returns a single entity which contains metadata about the particular Container and returns the following XML:

   1: <s:Container 
   2:     xmlns:s="http://schemas.microsoft.com/sitka/2008/03/" 
   3:     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
   4:     xmlns:x="http://www.w3.org/2001/XMLSchema">
   5:       <s:Id>LatinaSpecial</s:Id>
   6:       <s:Version>1234</s:Version>
   7: </s:Container>

As with Authority URIs appending a query to the end of a Container URI will return all entities which meet the query criteria for the particular Container.

Entity URI

An Entity URI is a Container URI followed by an Entity ID and returns a specific entity

https://duringlunch-01.data.database.windows.net/v1/PizzaRecipes/LatinaSpecial/

   1: <LatinaSpecial
   2:  xmlns:s="http://schemas.microsoft.com/sitka/2008/03/"
   3:  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   4:  xmlns:x="http://www.w3.org/2001/XMLSchema">
   5:  <s:Id>LatinaSpecialPizza<s:Id>
   6:  <s:Version>13453</s:Version>
   7:  <s:DisplayName xsi:type="x:string">Latina Special Pizza</s:DisplayName>    
   8:  <Rating xsi:type="x:string">Great</Rating>
   9:  <NumberOfTimesMade xsi:type="x:decimal">250</NumberOfTimesMade>
  10:  <Description xsi:type="x:string">A mouth watering pizza with a Latina flair</Description>
  11:  <Pepperoni xsi:type="x:decimal">30</Pepperoni>
  12:  <Cheese xsi:type="x:decimal">24</Cheese>
  13:  <Crema xsi:type="x:decimal">5</Crema>
  14:  <QuesoFresco xsi:type="x:decimal">40</QuesoFresco>
  15: </LatinaSpecial> 

Security Model

Every Authority has a single user name and password (owner), and once authorized for a specific authority end point, full control over the Authority and the data stored within it is granted. Accounts are secured by SDS issued user credentials and only allows for communication by https.

Next…Query Support

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Search

Disclaimer

The opinions expressed here are my own and do not represent my customers, my friends, my familys (well I would hope so) views in anyway. No bailar con monos borracho al comer su almuerzo.

© 2009 James Johnson

James Johnson

My views and opinions on running a .NET User Group, web development, evangelizing, mentoring, utilizing the latest technologies, living as a gringo in a Latin family, and, of course, life in general.

Join BizSpark

BizSpark provides qualified Startups with FREE* software and support getting their idea up and running.
There is no charge for signing up. However a minimal fee of $100 is required when you leave the program.

Recent Comments