<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Rob Tiffany &#187; Database</title>
	<atom:link href="http://robtiffany.com/tag/database/feed" rel="self" type="application/rss+xml" />
	<link>http://robtiffany.com</link>
	<description>Author, Software Architect, Speaker, Technology Executive, Former Navy Submariner</description>
	<lastBuildDate>Sat, 04 Feb 2012 22:55:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>What Developers in Small Companies are Using</title>
		<link>http://robtiffany.com/software/what-developers-in-small-companies-are-using</link>
		<comments>http://robtiffany.com/software/what-developers-in-small-companies-are-using#comments</comments>
		<pubDate>Fri, 09 Dec 2011 17:01:44 +0000</pubDate>
		<dc:creator>Rob Tiffany</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Bug Tracking]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Developer]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[Project Management]]></category>
		<category><![CDATA[Storage]]></category>
		<category><![CDATA[Text Editor]]></category>
		<category><![CDATA[Version Control]]></category>
		<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[Website Analytics]]></category>

		<guid isPermaLink="false">http://robtiffany.com/software/what-developers-in-small-companies-are-using</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><img src="http://api.viglink.com/api/click?format=go&amp;key=021de175e1e571c67cfaeea3c68d72e8&amp;loc=http%3A%2F%2Fwww.readwriteweb.com%2Fhack%2F2011%2F12%2Finfographic-what-tools-develop.php&amp;v=1&amp;libid=1323449648031&amp;out=http%3A%2F%2Frww.readwriteweb.netdna-cdn.com%2Fhack%2FBV%2520Developer%2520Infographic.jpg&amp;ref=http%3A%2F%2Fwww.readwriteweb.com%2F&amp;title=Infographic%3A%20What%20Tools%20Developers%20Actually%20Use&amp;txt=&amp;jsonp=vglnk_jsonp_13234496851722" width="1199" height="3687" /></p>
]]></content:encoded>
			<wfw:commentRss>http://robtiffany.com/software/what-developers-in-small-companies-are-using/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A Quick Note on Speedy, Scalable, Available Architectures</title>
		<link>http://robtiffany.com/architecture/a-quick-note-on-speedy-scalable-available-architectures</link>
		<comments>http://robtiffany.com/architecture/a-quick-note-on-speedy-scalable-available-architectures#comments</comments>
		<pubDate>Fri, 02 Dec 2011 15:23:09 +0000</pubDate>
		<dc:creator>Rob Tiffany</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Availability]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Cluster]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Horizontal Scale]]></category>
		<category><![CDATA[Load Balance]]></category>
		<category><![CDATA[NoSQL]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Private Cloud]]></category>
		<category><![CDATA[Queue]]></category>
		<category><![CDATA[Relational]]></category>
		<category><![CDATA[Replication]]></category>
		<category><![CDATA[Scalability]]></category>
		<category><![CDATA[Shard]]></category>
		<category><![CDATA[Speed]]></category>
		<category><![CDATA[Web Service]]></category>

		<guid isPermaLink="false">http://robtiffany.com/architecture/a-quick-note-on-speedy-scalable-available-architectures</guid>
		<description><![CDATA[Just a few thoughts on concepts needed to give mobile users of your SOA infrastructure the best, fastest User eXperience possible: If you care about speed &#38; scalability, your web service will always check the distributed cache before querying the database. If you have to get your answer from your database, make sure to add [...]]]></description>
			<content:encoded><![CDATA[<p>Just a few thoughts on concepts needed to give mobile users of your SOA infrastructure the best, fastest User eXperience possible:</p>
<ul>
<li>If you care about speed &amp; scalability, your web service will always check the distributed cache before querying the database.</li>
<li>If you have to get your answer from your database, make sure to add the answer to your distributed cache concurrently with returning it to the user.</li>
<li>Don’t ever call your primary database directly.  Call one of your horizontally-scaled relational or NoSQL replicas.</li>
<li>Use download-only replication to create as many read-only replicas as you need.  Your replicas can contain complete copies of the primary database or just shards of data as appropriate.</li>
<li>When sending data up from the clients to your servers, never let your web services insert, update, or delete directly against the primary database or the replicas.</li>
<li>Have your web services drop that uploaded data in a queue and update the distributed cache while letting worker processes perform those DML operations against the primary database.</li>
<li>Use peer-to-peer replication to maintain more than one read/write primary database at the top of your hierarchy.</li>
<li>Remember to create and maintain more than one hierarchy in different geographies using the same peer-to-peer replication to provide even more availability, scalability, and performance to your mobile users all around the world.</li>
<li>Your mobile users will be connecting to your service via slow, intermittent, unpredictable wireless data networks so always use small, efficient wire protocols like REST and data serialization like JSON.</li>
</ul>
<p>-Rob</p>
]]></content:encoded>
			<wfw:commentRss>http://robtiffany.com/architecture/a-quick-note-on-speedy-scalable-available-architectures/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sync Framework v4 is now Open Source, and ready to Connect any Device to SQL Server and SQL Azure</title>
		<link>http://robtiffany.com/sync-framework/sync-framework-v4-is-now-open-source-and-ready-to-connect-any-device-to-sql-server-and-sql-azure</link>
		<comments>http://robtiffany.com/sync-framework/sync-framework-v4-is-now-open-source-and-ready-to-connect-any-device-to-sql-server-and-sql-azure#comments</comments>
		<pubDate>Sun, 11 Sep 2011 20:54:27 +0000</pubDate>
		<dc:creator>Rob Tiffany</dc:creator>
				<category><![CDATA[Sync Framework]]></category>
		<category><![CDATA[Azure]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Consumerization]]></category>
		<category><![CDATA[Data]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[MEAP]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Mobile Enterprise Application Platform]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[SQL Azure]]></category>
		<category><![CDATA[SQL Server Compact]]></category>
		<category><![CDATA[Sync]]></category>
		<category><![CDATA[Synchronize]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[Windows Mobile]]></category>
		<category><![CDATA[Windows Phone 7]]></category>
		<category><![CDATA[Wireless]]></category>

		<guid isPermaLink="false">http://robtiffany.com/?p=1014</guid>
		<description><![CDATA[The profound effects of the Consumerization of IT (CoIT) is blurring the lines between consumers and the enterprise.  The fact that virtually every type of mobile device is now a candidate to make employees productive means that cross-platform, enabling technologies are a must.  Luckily, Microsoft has brought the power to synchronize data with either SQL Server [...]]]></description>
			<content:encoded><![CDATA[<p>The profound effects of the Consumerization of IT (CoIT) is blurring the lines between consumers and the enterprise.  The fact that virtually every type of mobile device is now a candidate to make employees productive means that cross-platform, enabling technologies are a must.  Luckily, Microsoft has brought the power to synchronize data with either SQL Server on-premise or SQL Azure in the cloud to the world of mobility.  If you&#8217;ve ever synched the music on your iPhone with iTunes, the calendar on your Android device with Gmail, or the Outlook email on your Windows Phone with Exchange, then you understand the importance of sync.  In my experience architecting and building enterprise mobile apps for the world&#8217;s largest organizations over the last decade, data sync has always been a critical ingredient.</p>
<p><a href="http://robtiffany.com/sync-framework/sync-framework-v4-is-now-open-source-and-ready-to-connect-any-device-to-sql-server-and-sql-azure/attachment/sql-azure_rgb_2" rel="attachment wp-att-1027"><img class="alignright size-medium wp-image-1027" title="SQL Azure" src="http://robtiffany.com/wp-content/uploads/2011/09/SQL-Azure_rgb_2-300x92.png" alt="" width="300" height="92" /></a><a href="http://robtiffany.com/sync-framework/sync-framework-v4-is-now-open-source-and-ready-to-connect-any-device-to-sql-server-and-sql-azure/attachment/microsoft-sql-server-2008" rel="attachment wp-att-1026"><img class="aligncenter size-medium wp-image-1026" title="SQL Server" src="http://robtiffany.com/wp-content/uploads/2011/09/microsoft-sql-server-2008-300x246.jpg" alt="" width="300" height="246" /></a></p>
<p>The new <strong><a title="Sync Framework Toolkit" href="http://code.msdn.microsoft.com/Sync-Framework-Toolkit-4dc10f0e" target="_blank">Sync Framework Toolkit</a></strong> found on MSDN builds on the existing Sync Framework 2.1&#8242;s ability to create disconnected applications, making it easier to expose data for synchronization to apps running on any client platform.  Where Sync Framework 2.1 required clients to be based on Windows, this free toolkit allows other Microsoft platforms to be used for offline clients such as Silverlight, Windows Phone 7, Windows Mobile, Windows Embedded Handheld, and new Windows Slates.   Additionally, non-Microsoft platforms such as iPhones, iPads, Android phones and tablets, Blackberries and browsers supporting HTML5 are all first-class sync citizens.  The secret is that we no longer require the installation of the Sync Framework runtime on client devices.  When coupled with use of an open protocol like <a title="OData" href="http://www.odata.org/" target="_blank">OData </a>for data transport, no platform or programming language is prevented from synchronizing data with our on-premise and cloud databases.  When the data arrives on your device, you can serialize it as JSON, or insert it into SQL Server Compact or SQLite depending on your platform preferences.</p>
<p><a href="http://robtiffany.com/sync-framework/sync-framework-v4-is-now-open-source-and-ready-to-connect-any-device-to-sql-server-and-sql-azure/attachment/sync" rel="attachment wp-att-1032"><img class="aligncenter size-full wp-image-1032" title="sync" src="http://robtiffany.com/wp-content/uploads/2011/09/sync.png" alt="" width="256" height="256" /></a>The Sync Framework Toolkit provides all the features enabled by the<a href="http://blogs.msdn.com/b/sync/archive/2010/11/16/sync-framework-4-0-october-2010-ctp-refreshed-on-11-16.aspx">Sync Framework 4.0 October 2010 CTP</a>.  We are releasing the toolkit as source code samples on MSDN with the source code utilizing Sync Framework 2.1.  Source code provides the flexibility to customize or extend the capabilities we have provided to suit your specific requirements. The client-side source code in the package is released under the <a href="http://www.apache.org/licenses/LICENSE-2.0.html">Apache 2.0 license</a> and the server-side source code under the <a href="http://mef.codeplex.com/license">MS-LPL license</a>.  The Sync Framework 2.1 is fully supported by Microsoft and the mobile-enabling source code is yours to use, build upon, and support for the apps you create.</p>
<p><a href="http://robtiffany.com/sync-framework/sync-framework-v4-is-now-open-source-and-ready-to-connect-any-device-to-sql-server-and-sql-azure/attachment/windowsslate" rel="attachment wp-att-1051"><img class="alignleft size-full wp-image-1051" title="WindowsSlate" src="http://robtiffany.com/wp-content/uploads/2011/09/WindowsSlate.png" alt="" width="182" height="115" /></a><a href="http://robtiffany.com/sync-framework/sync-framework-v4-is-now-open-source-and-ready-to-connect-any-device-to-sql-server-and-sql-azure/attachment/windowsphone" rel="attachment wp-att-1050"><img class="alignleft size-full wp-image-1050" title="WindowsPhone" src="http://robtiffany.com/wp-content/uploads/2011/09/WindowsPhone.png" alt="" width="152" height="153" /></a><a href="http://robtiffany.com/sync-framework/sync-framework-v4-is-now-open-source-and-ready-to-connect-any-device-to-sql-server-and-sql-azure/attachment/mc55a0_lg_us-en-2" rel="attachment wp-att-1048"><img class="alignleft size-thumbnail wp-image-1048" title="MC55A0_LG_US-EN" src="http://robtiffany.com/wp-content/uploads/2011/09/MC55A0_LG_US-EN1-150x150.jpg" alt="" width="150" height="150" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="http://robtiffany.com/sync-framework/sync-framework-v4-is-now-open-source-and-ready-to-connect-any-device-to-sql-server-and-sql-azure/attachment/html5_logo_512" rel="attachment wp-att-1045"><img class="alignleft size-thumbnail wp-image-1045" title="HTML5_Logo_512" src="http://robtiffany.com/wp-content/uploads/2011/09/HTML5_Logo_512-150x150.png" alt="" width="150" height="150" /></a><a href="http://robtiffany.com/sync-framework/sync-framework-v4-is-now-open-source-and-ready-to-connect-any-device-to-sql-server-and-sql-azure/attachment/mac" rel="attachment wp-att-1047"><img class="alignleft size-full wp-image-1047" title="Mac" src="http://robtiffany.com/wp-content/uploads/2011/09/Mac.png" alt="" width="184" height="106" /></a><a href="http://robtiffany.com/sync-framework/sync-framework-v4-is-now-open-source-and-ready-to-connect-any-device-to-sql-server-and-sql-azure/attachment/blackberry" rel="attachment wp-att-1044"><img class="alignleft size-full wp-image-1044" title="Blackberry" src="http://robtiffany.com/wp-content/uploads/2011/09/Blackberry.png" alt="" width="173" height="173" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="http://robtiffany.com/sync-framework/sync-framework-v4-is-now-open-source-and-ready-to-connect-any-device-to-sql-server-and-sql-azure/attachment/ipad" rel="attachment wp-att-1046"><img class="alignleft size-full wp-image-1046" title="iPad" src="http://robtiffany.com/wp-content/uploads/2011/09/iPad.png" alt="" width="113" height="144" /></a><a href="http://robtiffany.com/sync-framework/sync-framework-v4-is-now-open-source-and-ready-to-connect-any-device-to-sql-server-and-sql-azure/attachment/android" rel="attachment wp-att-1043"><img class="alignleft size-full wp-image-1043" title="Android" src="http://robtiffany.com/wp-content/uploads/2011/09/Android.png" alt="" width="154" height="153" /></a><a href="http://robtiffany.com/sync-framework/sync-framework-v4-is-now-open-source-and-ready-to-connect-any-device-to-sql-server-and-sql-azure/attachment/symbian" rel="attachment wp-att-1049"><img class="alignleft size-full wp-image-1049" title="Symbian" src="http://robtiffany.com/wp-content/uploads/2011/09/Symbian.png" alt="" width="152" height="163" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Now some of you might be wondering why you would use a sync technology to move data rather than SOAP or REST web services.  The reason has to do with performance and bandwidth efficiency.  Using SOA, one would retrieve all the data needed to the device in order to see what has changed in SQL Server.  The same goes for uploading data.  Using the Sync Framework Toolkit, only the changes, or deltas, are transmitted over the air.  The boosts performance and reduces bandwidth usage which saves time and money in a world of congested mobile data networks with capped mobile data plans.  You also get a feature called batching, which breaks up the data sent over wireless networks into manageable pieces.  This not only prevents you from blowing out your limited bandwidth, but it also keeps you from using too much RAM memory both on the server and your memory-constrained mobile device.  When combined with conflict resolution and advanced filtering, I&#8217;m sold!</p>
<p>I think you&#8217;ll find the Sync Framework Toolkit to be an immensely valuable component of your MEAP solutions for the enterprise as well as the ones you build for consumers.</p>
<p>Keep Synching,</p>
<p>Rob</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://robtiffany.com/sync-framework/sync-framework-v4-is-now-open-source-and-ready-to-connect-any-device-to-sql-server-and-sql-azure/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Performance and Memory Management Improvements with Windows Embedded Handheld</title>
		<link>http://robtiffany.com/windows-embedded-handheld/performance-and-memory-management-improvements-with-windows-embedded-handheld</link>
		<comments>http://robtiffany.com/windows-embedded-handheld/performance-and-memory-management-improvements-with-windows-embedded-handheld#comments</comments>
		<pubDate>Sun, 04 Sep 2011 15:49:39 +0000</pubDate>
		<dc:creator>Rob Tiffany</dc:creator>
				<category><![CDATA[Windows Embedded Handheld]]></category>
		<category><![CDATA[.NET Compact Framework]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Device Management]]></category>
		<category><![CDATA[Merge Replication]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Mobile Enterprise Application Platform]]></category>
		<category><![CDATA[RDA]]></category>
		<category><![CDATA[Remote Data Access]]></category>
		<category><![CDATA[SQL CE]]></category>
		<category><![CDATA[SQL Server Compact]]></category>
		<category><![CDATA[Sync]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Windows Mobile]]></category>
		<category><![CDATA[Wireless]]></category>

		<guid isPermaLink="false">http://robtiffany.com/?p=944</guid>
		<description><![CDATA[It should be no surprise that over 80% of enterprise handhelds shipped are running Windows Mobile or Windows Embedded Handheld. ]]></description>
			<content:encoded><![CDATA[<p>A lot has changed since the launch of Windows Phone in the Fall of 2010.  Microsoft now has a compelling phone platform that targets consumers inside and outside the office.  One thing that that hasn&#8217;t changed is the widespread use of Windows Embedded Handheld to solve tough enterprise mobility problems.  It should be no surprise that over 80% of enterprise handhelds shipped are running Windows Mobile or Windows Embedded Handheld.  They include support for barcode scanning, RFID reading, rugged hardware, every type of wireless, full device encryption, complete over-the-air software distribution and device managment support, FIPS compliance, and both capacitive touch and stylus operation.  On the application platform side of the equation, they have rich support for WinForm development using Visual Studio and the .NET Compact Framework, C++ and a full-featured database with built-in sync capabilities via SQL Server Compact.  They can easily communicate with WCF SOAP and REST web services running on Windows Servers on-premise or with Azure in the cloud.  Support for Merge Replication means faster time to market to get device synchronizing with SQL Server with almost no coding.</p>
<p><a href="http://robtiffany.com/windows-embedded-handheld/performance-and-memory-management-improvements-with-windows-embedded-handheld/attachment/motorola-es400" rel="attachment wp-att-951"><img class="alignleft size-medium wp-image-951" title="Windows Embedded Handheld" src="http://robtiffany.com/wp-content/uploads/2011/09/motorola-es400-144x300.jpg" alt="" width="144" height="300" /></a><a href="http://robtiffany.com/windows-embedded-handheld/performance-and-memory-management-improvements-with-windows-embedded-handheld/attachment/pp-psion-teklogix-12-6-10" rel="attachment wp-att-978"><img class="alignleft size-medium wp-image-978" title="pp-Psion-Teklogix-12-6-10" src="http://robtiffany.com/wp-content/uploads/2011/09/pp-Psion-Teklogix-12-6-10-183x300.jpg" alt="" width="183" height="300" /></a><a href="http://robtiffany.com/windows-embedded-handheld/performance-and-memory-management-improvements-with-windows-embedded-handheld/attachment/dolphin" rel="attachment wp-att-976"><img class="alignleft size-medium wp-image-976" title="dolphin" src="http://robtiffany.com/wp-content/uploads/2011/09/dolphin-163x300.jpg" alt="" width="163" height="300" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="http://robtiffany.com/windows-embedded-handheld/performance-and-memory-management-improvements-with-windows-embedded-handheld/attachment/intermec" rel="attachment wp-att-979"><img class="alignleft size-medium wp-image-979" title="intermec" src="http://robtiffany.com/wp-content/uploads/2011/09/intermec-140x300.jpg" alt="" width="140" height="300" /></a><a href="http://robtiffany.com/windows-embedded-handheld/performance-and-memory-management-improvements-with-windows-embedded-handheld/attachment/honeywell_99ex" rel="attachment wp-att-977"><img class="alignleft size-medium wp-image-977" title="honeywell_99ex" src="http://robtiffany.com/wp-content/uploads/2011/09/honeywell_99ex-127x300.jpg" alt="" width="127" height="300" /></a></p>
<p>Since Windows Embedded Handheld uses an advanced version of the operating system kernel used by Windows Mobile 6.5.3, many of the techniques and best practices I&#8217;ve taugh customers and developers all over the world still apply.  While it still uses the slotted memory model found in Windows CE 5 with 32 processes and 32 MB of memory per process, you&#8217;ll find that numerous enhancements and tuning has taken place to give your line of business apps more of what they need.  I&#8217;m talking about more memory per process and improved performance.  Therefore, I&#8217;d like you to sit back and watch the video of a presentation I delivered at Tech Ed in Los Angeles a couple of years ago so you can better learn what this mobile platform has to offer in the form of better memory management and improved performance:<br />
<iframe style="width: 512px; height: 384px;" src="http://channel9.msdn.com/Events/TechEd/Europe/2009/MOB401/player?w=512&amp;h=384" frameborder="0" scrolling="no" width="320" height="240"></iframe></p>
<p>A recent Gartner report recommends that organizations should stay with Windows Embedded Handheld as the best mobile platform for enterprise line of business needs.  Great devices are available from OEMs like Intermec, Motorola, Psion, and Honeywell just to name a few.  I hope this video helps you with any memory management or performance issues you may need to deal with in your enterprise mobile apps.</p>
<p>Best Regards,<br />
Rob</p>
]]></content:encoded>
			<wfw:commentRss>http://robtiffany.com/windows-embedded-handheld/performance-and-memory-management-improvements-with-windows-embedded-handheld/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Server Compact 4.0 Lands on the Web</title>
		<link>http://robtiffany.com/sql-server-compact/sql-server-compact-4-0-lands-on-the-web</link>
		<comments>http://robtiffany.com/sql-server-compact/sql-server-compact-4-0-lands-on-the-web#comments</comments>
		<pubDate>Tue, 18 Jan 2011 06:31:33 +0000</pubDate>
		<dc:creator>Rob Tiffany</dc:creator>
				<category><![CDATA[SQL Server Compact]]></category>
		<category><![CDATA[.NET Compact Framework]]></category>
		<category><![CDATA[ADO.NET]]></category>
		<category><![CDATA[Data]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[MEAP]]></category>
		<category><![CDATA[Merge Replication]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Mobile Enterprise Application Platform]]></category>
		<category><![CDATA[RDA]]></category>
		<category><![CDATA[Remote Data Access]]></category>
		<category><![CDATA[SQL CE]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SSCE]]></category>
		<category><![CDATA[Sync]]></category>
		<category><![CDATA[Sync Framework]]></category>
		<category><![CDATA[Synchronize]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Windows CE]]></category>
		<category><![CDATA[Windows Phone 7]]></category>
		<category><![CDATA[Windows phones]]></category>

		<guid isPermaLink="false">http://robtiffany.com/?p=486</guid>
		<description><![CDATA[With the new version 4.0, the little-database-that-could has grown up into a powerful server database ready to take on the web.]]></description>
			<content:encoded><![CDATA[<p>A decade has passed since I first started using SQL CE on my Compaq iPAQ.  What started as a great upgrade to Pocket Access turned into the ultimate embedded database for Windows CE, the Pocket PC, Windows Mobile and Windows Phones.  The one-two punch of Outlook Mobile synchronizing email with Exchange and SQL Server Compact synchronizing data with SQL Server helped set the mobile enterprise on fire.  In 2005, version 3.0 supported Windows Tablets and progressive enhancements to the code base led to full Windows support on both x86 and x64 platforms.  With the new version 4.0, the little-database-that-could has grown up into a powerful server database ready to take on the web. </p>
<p>We&#8217;ve come a long way and you&#8217;re probably wondering what qualifies this new embedded database to take on the Internet:</p>
<ul>
<li>Native support for x64 Windows Servers</li>
<li>Virtual memory usage has been optimized to ensure the database can support up to 256 open connections &#8211; (Are you actually using 256 pooled connections with your &#8220;Big&#8221; database today?)</li>
<li>Supports databases up to 4 GB in size &#8211; (Feel free to implement your own data sharding scheme<a href="http://robtiffany.com/wp-content/uploads/2011/01/sqlserver_sql_server_2008_logo.png"><img class="alignright size-medium wp-image-496" title="SQL Server Compact" src="http://robtiffany.com/wp-content/uploads/2011/01/sqlserver_sql_server_2008_logo-300x246.png" alt="SQL Server Compact" width="180" height="148" /></a>)</li>
<li>Developed, stress-tested, and tuned to support ASP.NET web applications</li>
<li>Avoids the interprocess communications performance hit by running in-process with your web application</li>
<li>Row-level locking to boost concurrency</li>
<li>Step up to Government + Military grade security SHA2 algorithm to secure data with FIPS compliance</li>
<li>Enhanced data reliability via true atomicity, consistency, isolation, and durability (ACID) support</li>
<li>Transaction support to commit and roll back grouped changes</li>
<li>Full referential integrity with cascading deletes and updates</li>
<li>Support ADO.NET Entity Framework 4 &#8211; (Do I hear WCF Data Services?)</li>
<li>Paging queries are supported via T-SQL syntax to only return the data you actually need</li>
</ul>
<p>Wow, that&#8217;s quite a list!  SQL Server Compact 4.0 databases are easily developed using the new WebMatrix IDE or through Visual Studio 2010 SP1.  I&#8217;m loving the new ASP.NET Web Pages.  It reminds me of the good old days of building web applications with Classic ASP back in the 90&#8242;s with Visual InterDev and Homesite.</p>
<p>What about Mobility?</p>
<p>Since SQL Server Compact owes its heritage to mobile and embedded versions of Windows, you might be wanting to know what our story is there.  The good news is that you can build and deploy v4.0 databases on Windows XP, Windows Vista, and Windows 7.  If you want to implement an occasionally-connected solution that utilizes the Sync Framework, Remote Data Access (RDA), or Merge Replication, you&#8217;ll need to stick with SQL Server Compact 3.5 SP2.  Time and resource-constraints prevented the Compact team from enabling these features.  Luckily, single-user WPF/WinForms database applications running on Windows Slates, laptops and Windows Embedded Handheld devices will work just fine with the v3.5 SP2 runtime.  Get a jumpstart with this by pickup up &#8220;Enterprise Data Synchronization with Microsoft SQL Server 2008 and SQL Server Compact 3.5 Mobile Merge Replication&#8221; at   <a href="http://www.amazon.com/Enterprise-Synchronization-Microsoft-Compact-Replication/dp/0979891213/ref=sr_1_1?s=books&amp;ie=UTF8&amp;qid=1281715114&amp;sr=1-1">http://www.amazon.com/Enterprise-Synchronization-Microsoft-Compact-Replication/dp/0979891213/ref=sr_1_1?s=books&amp;ie=UTF8&amp;qid=1281715114&amp;sr=1-1</a> to start building those MEAP solutions.</p>
<p>With the tidal wave of Windows Slates hitting the market, a secure, powerful mobile database that allows users to work offline and syncs with SQL Server is definitely going to be a hot item!</p>
<p>So run, don&#8217;t walk to the Microsoft Download site to download the Next-Gen database for the web:</p>
<p><a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=033cfb76-5382-44fb-bc7e-b3c8174832e2">http://www.microsoft.com/downloads/en/details.aspx?FamilyID=033cfb76-5382-44fb-bc7e-b3c8174832e2</a></p>
<p>If you need to support occasionally-connected mobile applications with sync capabilities on muliple Windows platforms, download SQL Server Compact 3.5 SP2:</p>
<p><a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=e497988a-c93a-404c-b161-3a0b323dce24">http://www.microsoft.com/downloads/en/details.aspx?FamilyID=e497988a-c93a-404c-b161-3a0b323dce24</a></p>
<p>Keep Syncing,</p>
<p>Rob</p>
]]></content:encoded>
			<wfw:commentRss>http://robtiffany.com/sql-server-compact/sql-server-compact-4-0-lands-on-the-web/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reducing SQL Server Sync I/O Contention :: Tip 3</title>
		<link>http://robtiffany.com/sql-server/reducing-sql-server-sync-io-contention-tip-3</link>
		<comments>http://robtiffany.com/sql-server/reducing-sql-server-sync-io-contention-tip-3#comments</comments>
		<pubDate>Mon, 10 Jan 2011 23:43:35 +0000</pubDate>
		<dc:creator>Rob Tiffany</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Data]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Merge Replication]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Mobile Enterprise Application Platform]]></category>
		<category><![CDATA[RDA]]></category>
		<category><![CDATA[Remote Data Access]]></category>
		<category><![CDATA[SQL Azure]]></category>
		<category><![CDATA[SQL CE]]></category>
		<category><![CDATA[SQL Server Compact]]></category>
		<category><![CDATA[SSCE]]></category>
		<category><![CDATA[Sync]]></category>
		<category><![CDATA[Sync Framework]]></category>
		<category><![CDATA[Synchronize]]></category>
		<category><![CDATA[Windows Phone 7]]></category>

		<guid isPermaLink="false">http://robtiffany.com/?p=475</guid>
		<description><![CDATA[Uniqueness is a key factor when synchronizing data between SQL Server/Azure and multiple endpoints like Slates and Smartphones.  With data simultaneously created and updated on servers and clients, ensuring rows are unique to avoid key collisions is critical.  As you know, each row is uniquely identified by its Primary Key.]]></description>
			<content:encoded><![CDATA[<h5>GUIDs and Clustered Indexes</h5>
<p>Uniqueness is a key factor when synchronizing data between SQL Server/Azure and multiple endpoints like Slates and Smartphones.  With data simultaneously created and updated on servers and clients, ensuring rows are unique to avoid key collisions is critical.  As you know, each row is uniquely identified by its Primary Key.</p>
<p><a href="http://robtiffany.com/wp-content/uploads/2011/01/key.png"><img class="alignleft size-medium wp-image-476" title="Primary Key" src="http://robtiffany.com/wp-content/uploads/2011/01/key-300x156.png" alt="Primary Key" width="300" height="156" /></a></p>
<p>When creating Primary Keys, it’s common to use a compound key based on things like account numbers, insert time and other appropriate business items.  It’s even more popular to create Identity Columns for the Primary Key based on an Int or BigInt data type based on what I see from my customers.  When you designate a column(s) to be a Primary Key, SQL Server automatically makes it a Clustered Index.  Clustered indexes are faster than normal indexes for sequential values because the B-Tree leaf nodes are the actual data pages on disk, rather than just pointers to data pages.</p>
<p>While Identity Columns work well in most database situations, they often break down in a data synchronization scenario since multiple clients could find themselves creating new rows using the same key value.  When these clients sync their data with SQL Server, key collisions would occur.  Merge Replication includes a feature that hands out blocks of Identity Ranges to each client to prevent this. </p>
<p>When using other Microsoft sync technologies like the Sync Framework or RDA, no such Identity Range mechanism exists and therefore I often see GUIDs utilized as Primary Keys to ensure uniqueness across all endpoints.  In fact, I see this more and more with Merge Replication too since SQL Server adds a GUID column to the end of each row for tracking purposes anyway.  Two birds get killed with one Uniqueidentifier stone. </p>
<p>Using the Uniqueidentifier data type is not necessarily a bad idea.  Despite the tradeoff of reduced join performance vs. integers, the solved uniqueness problem allows sync pros to sleep better at night.  The primary drawback with using GUIDs as Primary Keys goes back to the fact that SQL Server automatically gives those columns a Clustered Index.</p>
<p><strong>I thought Clustered Indexes were a good thing?</strong></p>
<p>They are a good thing when the values found in the indexed column are sequential.  Unfortunately, GUIDs generated with the default NewId() function are completely random and therefore create a serious performance problem.  All those mobile devices uploading captured data means lots of Inserts for SQL Server.  Inserting random key values like GUIDs can cause fragmentation in excess of 90% because new pages have to be allocated with rows pushed to the new page in order to insert the record on the existing page.  This performance-killing, space-wasting page splitting wouldn’t happen with sequential Integers or Datetime values since they actually help fill the existing page.</p>
<p> <strong>What about NEWSEQUENTIALID()?</strong></p>
<p>Generating your GUIDs on SQL Server with this function will dramatically reduce fragmentation and wasted space since it guarantees that each GUID will be sequential.  Unfortunately, this isn’t bulletproof.  If your Windows Server is restarted for any reason, your GUIDs may start from a lower range.  They’ll still be globally unique, but your fragmentation will increase and performance will decrease.  Also keep in mind that all the devices synchronizing with SQL Server will be creating their own GUIDs which blows the whole NEWSEQUENTIALID() strategy out of the water.</p>
<h5>Takeaway</h5>
<p>If you’re going to use the Uniqueidentifier data type for your Primary Keys and you plan to sync your data with RDA, the Sync Framework or Merge Replication, ensure that <strong>Create as Clustered == No</strong> for better performance.  You’ll still get fragmentation, but it will be closer to the ~30% range instead almost 100%.</p>
<p>Keep synching</p>
<p>Rob</p>
<div id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:bf960cbd-b9a9-41b8-9652-5bf27b02ff01">Technorati Tags: <a rel="tag" href="http://technorati.com/tags/SQL+Server">SQL Server</a>,<a rel="tag" href="http://technorati.com/tags/SQL+Server+Compact">SQL Server Compact</a>,<a rel="tag" href="http://technorati.com/tags/Sync">Sync</a>,<a rel="tag" href="http://technorati.com/tags/GUID">GUID</a>,<a rel="tag" href="http://technorati.com/tags/Clustered+Index">Clustered Index</a>,<a rel="tag" href="http://technorati.com/tags/Microsoft">Microsoft</a>,<a rel="tag" href="http://technorati.com/tags/Windows">Windows</a>,<a rel="tag" href="http://technorati.com/tags/SQL+Azure">SQL Azure</a>,<a rel="tag" href="http://technorati.com/tags/MEAP">MEAP</a></div>
]]></content:encoded>
			<wfw:commentRss>http://robtiffany.com/sql-server/reducing-sql-server-sync-io-contention-tip-3/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Reducing SQL Server I/O Contention during Sync :: Tip 2</title>
		<link>http://robtiffany.com/sql-server/reducing-sql-server-io-contention-during-sync-tip-2</link>
		<comments>http://robtiffany.com/sql-server/reducing-sql-server-io-contention-during-sync-tip-2#comments</comments>
		<pubDate>Sat, 08 Jan 2011 01:07:07 +0000</pubDate>
		<dc:creator>Rob Tiffany</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Data]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Isolated Storage]]></category>
		<category><![CDATA[Merge Replication]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[RDA]]></category>
		<category><![CDATA[Remote Data Access]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Slate]]></category>
		<category><![CDATA[SQL Azure]]></category>
		<category><![CDATA[SQL CE]]></category>
		<category><![CDATA[SQL Compact]]></category>
		<category><![CDATA[SQL Compact 4]]></category>
		<category><![CDATA[SQL Server Compact]]></category>
		<category><![CDATA[SQLCE]]></category>
		<category><![CDATA[SSCE]]></category>
		<category><![CDATA[Sync]]></category>
		<category><![CDATA[Sync Framework]]></category>
		<category><![CDATA[Synchronize]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Windows Phone 7]]></category>
		<category><![CDATA[Windows phones]]></category>

		<guid isPermaLink="false">http://robtiffany.com/?p=455</guid>
		<description><![CDATA[All DBAs know that Joining tables on non-indexed columns is the most expensive operation SQL Server can perform.  ]]></description>
			<content:encoded><![CDATA[<h5>Indexing Join Columns</h5>
<p>In my last Sync/Contention post, I beat up on a select group of SAN administrators who aren&#8217;t willing to go the extra mile to optimize the very heart of their organization, SQL Server.  You guys know who you are.</p>
<p>This time, I want to look at something more basic, yet often overlooked.<a href="http://robtiffany.com/wp-content/uploads/2011/01/emc_symmetrix_vmax-1024x571.jpg"><img class="size-full wp-image-458 alignnone" title="Database Storage" src="http://robtiffany.com/wp-content/uploads/2011/01/emc_symmetrix_vmax-1024x571.jpg" alt="" width="640" height="356" /></a></p>
<p>All DBAs know that Joining tables on non-indexed columns is the most expensive operation SQL Server can perform.  Amazingly, I run into this problem over and over with many of my customers.  Sync technologies like the Sync Framework, RDA and Merge Replication allow for varying levels of server-side filtering.  This is a popular feature used to reduce the size of the tables and rows being downloaded to Silverlight Isolated Storage or SQL Server Compact. </p>
<p>It&#8217;s also a performance killer when tables and columns participating in a Join filter are not properly indexed.  Keeping rows locked longer than necessary creates undue blocking and deadlocking.  It also creates unhappy slate and smartphone users who have to wait longer for their sync to complete.</p>
<p>Do yourselft a favor and go take a look at all the filters you&#8217;ve created and makes sure that you have indexes on all those Joined columns.</p>
<p>Keep synching,</p>
<p>Rob</p>
]]></content:encoded>
			<wfw:commentRss>http://robtiffany.com/sql-server/reducing-sql-server-io-contention-during-sync-tip-2/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reducing SQL Server I/O Contention during Sync :: Tip 1</title>
		<link>http://robtiffany.com/sql-server/reducing-sql-server-io-contention-during-sync-tip-1</link>
		<comments>http://robtiffany.com/sql-server/reducing-sql-server-io-contention-during-sync-tip-1#comments</comments>
		<pubDate>Thu, 06 Jan 2011 06:16:55 +0000</pubDate>
		<dc:creator>Rob Tiffany</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Azure]]></category>
		<category><![CDATA[Data]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[I/O]]></category>
		<category><![CDATA[LUN]]></category>
		<category><![CDATA[Merge Replication]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Mobile Enterprise Application Platform]]></category>
		<category><![CDATA[RAID]]></category>
		<category><![CDATA[Remote Data Access]]></category>
		<category><![CDATA[SAN]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[SQL Azure]]></category>
		<category><![CDATA[SQL Server Compact]]></category>
		<category><![CDATA[SSCE]]></category>
		<category><![CDATA[SSIS]]></category>
		<category><![CDATA[Sync]]></category>
		<category><![CDATA[Sync Framework]]></category>
		<category><![CDATA[Synchronize]]></category>
		<category><![CDATA[tempdb]]></category>
		<category><![CDATA[Transaction Logs]]></category>
		<category><![CDATA[Windows Mobile]]></category>
		<category><![CDATA[Windows Phone 7]]></category>

		<guid isPermaLink="false">http://robtiffany.com/?p=447</guid>
		<description><![CDATA[The act of tracking changes made by each SQL Server Compact or Silverlight sync subscriber can cause a lot of locking and blocking on the server.]]></description>
			<content:encoded><![CDATA[<h5>RAID</h5>
<p>Sync technologies like Merge Replication and the Sync Framework track changes on SQL Server using triggers, stored procedures and special tracking tables.  The act of tracking changes made by each SQL Server Compact or Silverlight sync subscriber can cause a lot of locking and blocking on the server.  This diminishes performance and sometimes leads to deadlocks. <a href="http://robtiffany.com/wp-content/uploads/2011/01/x3_wss-storageserver2_2.jpg"><img class="alignleft size-full wp-image-450" title="SAN Storage" src="http://robtiffany.com/wp-content/uploads/2011/01/x3_wss-storageserver2_2.jpg" alt="SAN Storage" width="540" height="186" /></a></p>
<p>Therefore, don&#8217;t listen to your SAN administrator when he says the RAID 5 will do.  RAID 1 or 10 must always be used for all databases, tempdb, and transaction logs.  Furthermore, each of these database objects must be placed on their own dedicated RAID arrays.  No sharing!  Remembers, as a DBA and sync expert, knowledge of SAN configuration must always be part of your skillset.</p>
<p>Keeping synching,</p>
<p>Rob</p>
]]></content:encoded>
			<wfw:commentRss>http://robtiffany.com/sql-server/reducing-sql-server-io-contention-during-sync-tip-1/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows Phone 7 Line of Business App Dev :: Improving the In-Memory Database</title>
		<link>http://robtiffany.com/windows-phone-7/windows-phone-7-line-of-business-app-dev-improving-the-in-memory-database</link>
		<comments>http://robtiffany.com/windows-phone-7/windows-phone-7-line-of-business-app-dev-improving-the-in-memory-database#comments</comments>
		<pubDate>Sat, 27 Nov 2010 07:19:51 +0000</pubDate>
		<dc:creator>Rob Tiffany</dc:creator>
				<category><![CDATA[Windows Phone 7]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[AutoFlush]]></category>
		<category><![CDATA[Azure]]></category>
		<category><![CDATA[Chage-tracking]]></category>
		<category><![CDATA[Column]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[DataContractJsonSerializer]]></category>
		<category><![CDATA[DML]]></category>
		<category><![CDATA[Isolated Storage]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[ObservableCollection]]></category>
		<category><![CDATA[Occasionally-connected]]></category>
		<category><![CDATA[RDA]]></category>
		<category><![CDATA[Remote Data Access]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[Row]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Singleton]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Azure]]></category>
		<category><![CDATA[SQL Server Compact]]></category>
		<category><![CDATA[SQLCE]]></category>
		<category><![CDATA[Table]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[Windows Azure]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[XmlSerializer]]></category>

		<guid isPermaLink="false">http://robtiffany.com/windows-phone-7/windows-phone-7-line-of-business-app-dev-improving-the-in-memory-database</guid>
		<description><![CDATA[About a month ago, I wrote an article intended to help you fill some of the gaps left by the missing SQL Server Compact database.&#160; Since your Windows Phone 7 Silverlight app is consuming an ObservableCollection of objects streaming down from Windows Azure and SQL Azure, it makes sense to organize those objects in a [...]]]></description>
			<content:encoded><![CDATA[<p>About a month ago, I wrote an article intended to help you fill some of the gaps left by the missing <strong>SQL Server Compact</strong> database.&#160; Since your <strong>Windows Phone 7 Silverlight</strong> app is consuming an <strong>ObservableCollection</strong> of objects streaming down from <strong>Windows Azure</strong> and <strong>SQL Azure</strong>, it makes sense to organize those objects in a database-like format that’s easy to work with.&#160; If you’ve ever worked with <strong>Remote Data Access (RDA)</strong> in the past, the notion of <strong>pre-fetching</strong> multiple tables to work with locally should look familiar.&#160; </p>
<p>In this case, each <strong>ObservableCollection</strong> represents a table, each object represents a row, and each object property represents a column.&#160; I had you create a <strong>Singleton</strong> class to hold all these objects in memory to serve as the database.&#160; The fact that Silverlight supports <strong>Language Integrated Query (LINQ)</strong> means that you can use <strong>SQL-like statements</strong> to work with the multiple, ObservableCollections of objects.&#160; </p>
<p>If you’re wondering why I have you cache everything in memory in a Singleton, there’s a few reasons.&#160; For starters, it makes it easy to query everything with <strong>LINQ</strong> with the fastest performance possible for single and multi-table JOINs.&#160; Secondly, I don’t represent a <strong>Microsoft</strong> product group and therefore wouldn’t engineer an unsupported provider that can query subsets of serialized data from files residing in <strong>Isolated Storage</strong>.&#160; Finally, I don’t want you to accidentally find yourself with <strong>multiple instances</strong> of the same ObservableCollection when pulling data down from <strong>Azure</strong> or loading it from Isolated Storage.&#160; Forcing everything into a Singleton prevents you <strong>wasting memory</strong> or updating objects in the wrong instance of an ObservableCollection.&#160; An inconsistent database is not a good thing.&#160; Don’t worry, you can control which tables are loaded into memory.</p>
<p>So what is this article all about and what are the <strong>“improvements”</strong> I’m talking about?</p>
<p>This time around, I’m going to focus on <strong>saving</strong>, <strong>loading</strong> and <strong>deleting</strong> the <strong>serialized</strong> ObservableCollections from Isolated Storage.&#160; In that last article, I showed you how to serialize/de-serialize the ObservableCollections to and from Isolated Storage using the <strong>XmlSerializer</strong>.&#160; This made it easy for you to save each table to its own XML file which sounds pretty cool. </p>
<p>So what’s wrong with this?</p>
<p>Saving anything as <strong>XML</strong> means that you’re using the largest, most verbose form of serialization.&#160; After hearing me preach about the virtues of doing <strong>SOA</strong> with <strong>WCF REST + JSON</strong>, using the <strong>XmlSerializer</strong> probably seems out of place.&#160; Luckily, the <strong>DataContractJsonSerializer</strong> supported by <strong>Silverlight</strong> on <strong>Windows Phone 7</strong> gives you the most <strong>efficient wire protocol</strong> for data-in-transit can also be used to save those same .NET objects to Isolated Storage.&#160; So the first improvement in this article comes from shrinking the size of the tables and improving the efficiency of the serialization/de-serializing operations to Isolated Storage using out-of-the-box functionality.&#160; </p>
<p>While going from XML to JSON for your serializing might be good enough, there’s another improvement in the way you write the code that will make this much easier to implement for your own projects.&#160; A look back to the previous article reveals a <strong>tight coupling</strong> between the tables that needed to be saved/loaded and the code needed to make that happen.&#160; This meant that you would have to create a <strong>SaveTable</strong> and <strong>LoadTable</strong> method for each table that you wanted to retrieve from <strong>Azure</strong>.&#160; The new code you’re about to see is <strong>generic</strong> and allows you to use a single SaveTable and LoadTable method even if you decide to download 100 tables.</p>
<p>Enough talk already, let’s see some code.&#160; Launch your <strong>ContosoCloud</strong> solution in <strong>Visual Studio</strong> and open <strong>Database.cs</strong>.&#160; I want you to overwrite the existing code with the code shown below:</p>
<p><font size="1"><strong>using System;       <br />using System.Net;        <br />using System.Windows;        <br />using System.Collections.Generic;        <br />using System.Collections.ObjectModel;        <br />using System.IO.IsolatedStorage;        <br />using System.Runtime.Serialization.Json;</strong></font></p>
<p><font size="1"><strong>namespace ContosoPhone       <br />{        <br />&#160;&#160;&#160; sealed class Database        <br />&#160;&#160;&#160; {        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; //Declare Instance        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; private static readonly Database instance = new Database();</strong></font></p>
<p><font size="1"><strong>&#160;&#160;&#160;&#160;&#160;&#160;&#160; //Private Constructor       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; private Database() { }</strong></font></p>
<p><font size="1"><strong>&#160;&#160;&#160;&#160;&#160;&#160;&#160; //The entry point into this Database       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; public static Database Instance        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; get        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return instance;        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</strong></font></p>
<p><font size="1"><strong>&#160;&#160;&#160;&#160;&#160;&#160;&#160; //Serialize ObservableCollection to JSON in Isolated Storage       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; public void SaveTable&lt;T&gt;(T tableToSave, string tableName)        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (tableToSave != null)        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; using (IsolatedStorageFileStream stream = store.CreateFile(tableName + &quot;.txt&quot;))        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(T));        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; serializer.WriteObject(stream, tableToSave);        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; else        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; throw new Exception(&quot;Table is empty&quot;);        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</strong></font></p>
<p><font size="1"><strong>&#160;&#160;&#160;&#160;&#160;&#160;&#160; //Deserialize ObservableCollection from JSON in Isolated Storage       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; public T LoadTable&lt;T&gt;(T tableToLoad, string tableName)        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (store.FileExists(tableName + &quot;.txt&quot;))        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; using (IsolatedStorageFileStream stream = store.OpenFile(tableName + &quot;.txt&quot;, System.IO.FileMode.Open))        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(T));        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return (T)serializer.ReadObject(stream);        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; else        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; throw new Exception(&quot;Table not found&quot;);        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</strong></font></p>
<p><font size="1"><strong>&#160;&#160;&#160;&#160;&#160;&#160;&#160; //Delete ObservableCollection from Isolated Storage       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; public void DropTable(string tableName)        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (store.FileExists(tableName + &quot;.txt&quot;))        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; store.DeleteFile(tableName + &quot;.txt&quot;);        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; else        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; throw new Exception(&quot;Table not found&quot;);        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</strong></font></p>
<p><font size="1"><strong>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; //Declare Private Table Variables        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; private ObservableCollection&lt;Customer&gt; customerTable = null;</strong></font></p>
<p><font size="1"><strong>&#160;&#160;&#160;&#160;&#160;&#160;&#160; //Customer Table       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; public ObservableCollection&lt;Customer&gt; Customers        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; get { return customerTable; }        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; set { customerTable = value; }        <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }        <br />&#160;&#160;&#160; }        <br />}        <br /></strong></font></p>
<p>&#160;</p>
<p>Looking from top to bottom, the first change you’ll notice is the new <strong>SaveTable</strong> method where you pass in the desired <strong>ObservableCollection</strong> and <strong>table name</strong> in order to serialize it as <strong>JSON</strong> using the <strong>DataContractJsonSerializer</strong>.&#160; The next method down the list is <strong>LoadTable</strong> where you pass in the same parameters as <strong>SaveTable</strong> but you get back a <strong>de-serialized</strong> ObservableCollection.&#160; The last new method in the Database Singleton is <strong>DropTable</strong> which simply <strong>deletes</strong> the serialized table from Isolated Storage if you don’t need it anymore.</p>
<p>So how do you call this code?</p>
<p>Bring up <strong>MainPage.xaml.cs</strong>, and find the click event for <strong>Save button</strong>.&#160; Delete the existing <strong>XmlSerializer</strong> code and replace it with the following:</p>
<p><font size="1"><strong>try       <br />{        <br />&#160;&#160;&#160; Database.Instance.SaveTable&lt;ObservableCollection&lt;Customer&gt;&gt;(Database.Instance.Customers, &quot;Customers&quot;);        <br />}        <br />catch (Exception ex)        <br />{        <br />&#160;&#160;&#160; MessageBox.Show(ex.Message);        <br />}</strong></font></p>
<p>The code above shows you how to call the <strong>SaveTable</strong> method in the Singleton with the appropriate syntax to pass in the ObservableCollection type as well as actual ObservableCollection value and name.</p>
<p>Now find the click event for the <strong>Load button</strong>, delete the existing code and paste in the following:</p>
<p><font size="1"><strong>try       <br />{        <br />&#160;&#160;&#160; Database.Instance.Customers = Database.Instance.LoadTable&lt;ObservableCollection&lt;Customer&gt;&gt;(Database.Instance.Customers, &quot;Customers&quot;);        <br />}        <br />catch (Exception ex)        <br />{        <br />&#160;&#160;&#160; MessageBox.Show(ex.Message);        <br />}</strong></font></p>
<p>This code looks pretty much the same as the <strong>SaveTable</strong> code except that you set <strong>Database.Instance.Customers</strong> equal to the return value from the method.&#160; For completeness sake, drop another button on <strong>MainPage.xaml</strong> and call it <strong>Drop</strong>.&#160; In its click event, paste in the following code:</p>
<p><font size="1"><strong>try       <br />{        <br />&#160;&#160;&#160; Database.Instance.DropTable(&quot;Customers&quot;);        <br />}        <br />catch (Exception ex)        <br />{        <br />&#160;&#160;&#160; MessageBox.Show(ex.Message);        <br />}</strong></font></p>
<p>For this code, just pass in the name of the table you want to delete from Isolated Storage and it’s gone.</p>
<p>It’s time to hit F5 so you can see how things behave.</p>
<p><a href="http://robtiffany.com/wp-content/uploads/2010/11/phone7.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="phone7" border="0" alt="phone7" src="http://robtiffany.com/wp-content/uploads/2010/11/phone7_thumb.png" width="258" height="484" /></a></p>
<p>When your app comes to life in the emulator, I want you to exercise the system by <strong>Getting</strong>, <strong>Adding</strong>, <strong>Updating</strong> and <strong>Deleting</strong> Customers.&#160; In between, I want you to tap the Save button,<strong> close the app</strong>, reload the app and tap the Load button and then View Customers to ensure you’re seeing the list of Customers you expect.&#160; Keep in mind that when you Save, you <strong>overwrite the previously saved table</strong>.&#160; Likewise, when you Load, you <strong>overwrite the current in-memory ObservableCollection</strong>.&#160; Additionally, Saving, Loading, and Dropping tables that don’t exist should throw an appropriate error message.</p>
<p>So what’s the big takeaway for these tweaks I’ve made to the in-memory database?</p>
<p>While switching serialization from <strong>XML</strong> to <strong>JSON</strong> is a great improvement in size and efficiency, I truly believe that making the SaveTable and LoadTable methods <strong>generic</strong> and <strong>reusable</strong> will <strong>boost developer productivity</strong>.&#160; The new ease with which you can Save and Load 1, 10 or even 1,000 tables makes this more attractive to mobile developers that need to work with local data.</p>
<p>So where do we go from here?</p>
<p>You now have some of the basic elements of a database on <strong>Windows Phone 7</strong>.&#160; You don’t have <strong>ACID</strong> support, <strong>indexes</strong>, <strong>stored procedures</strong> or <strong>triggers</strong> but you have a foundation to build on.&#160; So what should be built next?&#160; </p>
<p>To help ensure <strong>database consistency</strong>, I would add an <strong>AutoFlush</strong> feature next.&#160; <strong>SQL Server Compact</strong> flushes its data to disk every 10 seconds and there’s nothing to prevent you from using the SaveTable method to do the same.&#160; A timer set to fire at a user-specified interval that <strong>iterates</strong> through all the ObservableCollections and saves them will help keep your data safe from <strong>battery loss</strong> and unforeseen system failures.&#160; The fact that your app can be <strong>tombstoned</strong> at any moment when a user taps the Back button makes an AutoFlush feature even more important.</p>
<p>Anything else?</p>
<p>At the beginning of this article I mentioned <strong>RDA</strong> which is a simple form of data synchronization.&#160; It’s simple because it only tracks changes on the client but not the server.&#160; To find out what’s new or changed on the server, RDA requires local tables on the device to be dropped and then re-downloaded from SQL Server.&#160; With the system I’ve built and described throughout this series of articles, we already have this brute force functionality.&#160; So what’s missing is <strong>client-side change tracking</strong>.&#160; To do this, I would need to add code that fires during INSERTS, UPDATES, and DELETES and then writes the appropriate information to local tracking tables.&#160; To push those changes back to <strong>SQL Azure</strong>, appropriate code would need to call <strong>WCF REST + JSON</strong> Services that execute <strong>DML</strong> code on <strong>Windows Azure</strong>.</p>
<p>I hope with the improvements I’ve made to the in-memory database in this article, you’ll feel even more empowered to build <strong>occasionally-connected</strong> Windows Phone 7 solutions for consumers and the enterprise.</p>
<p>Keep coding!</p>
<p>-Rob</p>
]]></content:encoded>
			<wfw:commentRss>http://robtiffany.com/windows-phone-7/windows-phone-7-line-of-business-app-dev-improving-the-in-memory-database/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Windows Phone 7 Demo Fest Tech Ed Video</title>
		<link>http://robtiffany.com/windows-phone-7/windows-phone-7-demo-fest-tech-ed-video</link>
		<comments>http://robtiffany.com/windows-phone-7/windows-phone-7-demo-fest-tech-ed-video#comments</comments>
		<pubDate>Mon, 15 Nov 2010 21:21:55 +0000</pubDate>
		<dc:creator>Rob Tiffany</dc:creator>
				<category><![CDATA[Windows Phone 7]]></category>
		<category><![CDATA[Azure]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Exchange Server]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Sharepoint]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[SQL Azure]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Sync]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[Wireless]]></category>

		<guid isPermaLink="false">http://robtiffany.com/?p=398</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><object class="player" width="645" height="363" type="application/x-silverlight-2" data="data:application/x-silverlight-2,"><param value="http://www.msteched.com/ClientBin/players/VideoPlayer2009_03_27.xap" name="source" /><param value="m=http://ecn.channel9.msdn.com/o9/te/Europe/2010/wmv/wph103-lnc.wmv,thumbnail=http://www.msteched.com/Skins/TechEdOnline/Styles/images/DefaultPlayerBackground.png,autohide=true,showembed=true" name="initParams" /><param value="#00000000" name="background" /><param name="minRuntimeVersion" value="3.0.50106.0" /><param name="windowless" value="true" /><param name="enableGPUAcceleration" value="true" /><param name="autoUpgrade" value="true" /><a href="http://go.microsoft.com/fwlink/?LinkID=149156&#038;v=3.0.50106.0" style="text-decoration:none"><br />
	  <img src="http://www.msteched.com/Skins/TechEdOnline/Styles/images/NoSilverlight.jpg" alt="Get Microsoft Silverlight" style="border-style:none"/><br />
  </a><br />
</object></p>
]]></content:encoded>
			<wfw:commentRss>http://robtiffany.com/windows-phone-7/windows-phone-7-demo-fest-tech-ed-video/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://ecn.channel9.msdn.com/o9/te/Europe/2010/wmv/wph103-lnc.wmv" length="139729637" type="video/asf" />
		</item>
	</channel>
</rss>

