Mike Taulty's Blog
Bits and Bytes from Microsoft UK
Experimenting with Windows Azure Mobiles Services (Round 2)

Blogs

Mike Taulty's Blog

Elsewhere

Archives

One of the things that I was looking at in my post on Azure Mobile Services the other day was the idea of creating a ‘virtual table’ or a view which represented a join across two tables.

For example, imagine I have a new service mtaultyTest.azure-mobile.net where I’ve defined a person table;

image

and an address table;

image

and then if I insert a few rows;

image

image

and then I can very easily select data from either data with an HTTP GET but if I wanted to join the tables (server-side) it’s a little more complex because I’d have to alter the read script on the person table to automatically join to Address and return that dataset or I could alter the read script on the address table.

However, I don’t really want to alter either script and so (as in the previous post) I create a personAddress table where my hope is to join the tables together in a read script and present a ‘view’.

In the previous post while I knew that I could create a read script on personAddress, I didn’t know how I could grab the details of the query (against personAddress) with a view to trying to redirect it towards another table such as person. I asked around and Paul gave me some really useful info although it’s not quite going to get me where I want to be in this particular post.

Here’s the info that I wasn’t aware of - imagine I’m sending a query like this to the person table;

image

on the server-side, I can pick up the details of that query in a read script by making a call to getComponents();

 

image

and the log output of this looks like;

image

i.e. it gives me all the information I need to pull the query apart (albeit in a way that’s not documented against Azure Mobile Services right now as far as I know).

There’s a corresponding setComponents method which promises the idea of being able to change the query. Clearing the read script from my person table,for my personAddress table I thought that I might be able to write a read script like;

image

and, in theory, this does work and you can alter the properties like skip, take, includeTotalCount and so on but in the current preview you can’t actually alter the table property which is what I was wanting to do in order to query a different table than the one that the script is directly targeted at.

I believe that this might change in the future so I’ll revisit this idea as/when the preview moves along but I thought I’d share the getComponents()/setComponents() part.


Posted Thu, Sep 27 2012 9:16 AM by mtaulty

Comments

Dean wrote re: Experimenting with Windows Azure Mobiles Services (Round 2)
on Fri, Sep 28 2012 9:13 AM

Hi Mike,

I noticed from your first article a lot of Async goodness in the example. Do you have any good resources for Async. Are you able to do a blog on Async as it is now (since your ctp blog) to give us some tips and gotchas to look out for?

could you do a simple map reduce against azure maybe something like a bank with  a weeks worth of say millions of transaction getting some pivots on that data. I m interested in doing something like the Carter overkill analytics but using azure with async running some osrt of algo in the cloud?

thanks

mtaulty wrote re: Experimenting with Windows Azure Mobiles Services (Round 2)
on Sat, Sep 29 2012 8:32 PM

Dean,

Certainly at the UK Windows 8 Camps we're doing we meet a lot of developers who are new to async/await and perhaps Tasks and in the earlier days I was spending around 30 minutes trying to talk through it in the hope of helping out a little.

I might try and write something up or make some screencasts or similar. Time is tight at the moment :-)

Mike.

tatabánya nyelvoktatás wrote re: Experimenting with Windows Azure Mobiles Services (Round 2)
on Mon, Oct 1 2012 3:01 PM

"...we meet a lot of developers who are new to async/await and perhaps..."

not just in the UK, not just in the UK. Any post are welcome!

Dylan wrote re: Experimenting with Windows Azure Mobiles Services (Round 2)
on Thu, Oct 4 2012 7:22 PM

Hi Mike,

I think you're heading down a wrong path here. Table storage in Azure is fundamentally different than relational databases. I'd say that in this case the best option is to dump a combination of that data into a third table. If you think of the tables as being ViewModels from the Silverlight days it might clear up a bit. I try and restrict the amount of data manipulation I need to do in table storage to enable quick retrieval requests. Of course, you may need a background "grooming" process that updates all the tables should the value change in one but some good data storage design upfront can reduce this. In your case there is no reason to have separate tables (but I understand it's just a demo)

mtaulty wrote re: Experimenting with Windows Azure Mobiles Services (Round 2)
on Fri, Oct 5 2012 12:21 AM

Hi Dylan,

I hear you although isn't my data here stored in a relational SQL Server rather than in Azure Table Storage?

Thanks,

Mike.

Mike wrote re: Experimenting with Windows Azure Mobiles Services (Round 2)
on Wed, Nov 21 2012 8:24 PM

Nice tip - I used this approach to redirect my queries to a view that decorated the table with additional information.

Mike Taulty's Blog wrote Azure Mobile Services Update–Custom APIs
on Fri, Jul 5 2013 3:43 PM

Three weeks ago, Scott Guthrie posted about updates to Azure Mobile Services – I’ve written a little