SQL Data Services Adventure – Day 3

By James at November 29, 2008 08:23
Filed Under: SQL Data Services

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

Comments (2) -

12/2/2008 8:08:46 AM #

vardis

Good model. Thanks for the info.

vardis | Reply

12/2/2008 10:32:23 AM #

geoff

good post

geoff | Reply

Add comment




  Country flag
biuquote
  • Comment
  • Preview
Loading


About the author

James James is a five time and current Microsoft MVP in Client App Development, a Telerik Insider, a past Director on the INETA North America Board, a husband and dad, and has been developing software since the early days of Laser Discs and HyperCard stacks. As the Founder and President of the Inland Empire .NET User's Group, he has fondly watched it grow from a twice-a-month, early Saturday morning group of five in 2003, to a robust and rambunctious gathering of all types and sizes of .NET developers.

James loves to dig deep into the latest cutting edge technologies - sometimes with spectacular disasters - and spread the word about the latest and greatest bits, getting people excited about developing web sites and applications on the .NET platform, and using the best tools for the job. He tries to blog as often as he can, but usually gets distracted by EF, LINQ, MVC, ASP, SQL, XML, and most other types of acronyms. To keep calm James plays a mean Djembe and tries to practice his violin. You can follow him on twitter at @latringo.

And as usual, the comments, suggestions, writings and rants are my own, and really shouldn't reflect the opinions of my employer. That is, unless it really does.

James Twitter Feed

Recent Comments

Comment RSS

Month List