<?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>iBlog, iByte, iBrianiBlog, iByte, iBrian &#187; Database</title>
	<atom:link href="http://blog.brianbuikema.com/category/database/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.brianbuikema.com</link>
	<description>Technology Moves as Fast as We Move It by Brian Buikema</description>
	<lastBuildDate>Tue, 05 Mar 2013 15:33:33 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>MongoDB Sharding:  A Detailed Overview and 15 Minute High Speed Read</title>
		<link>http://blog.brianbuikema.com/2011/01/mongodb-sharding-a-detailed-overview-and-15-minute-high-speed-read/</link>
		<comments>http://blog.brianbuikema.com/2011/01/mongodb-sharding-a-detailed-overview-and-15-minute-high-speed-read/#comments</comments>
		<pubDate>Sat, 29 Jan 2011 03:20:30 +0000</pubDate>
		<dc:creator>Brian Buikema</dc:creator>
				<category><![CDATA[Architecture & Design]]></category>
		<category><![CDATA[Cloud Computing]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Document Repository]]></category>
		<category><![CDATA[Mongodb]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Ubunto]]></category>
		<category><![CDATA[architecture]]></category>
		<category><![CDATA[cloudcomputing]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[documentrepository]]></category>
		<category><![CDATA[nosql]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://blog.brianbuikema.com/?p=1265</guid>
		<description><![CDATA[Scaling is a key feature of MongoDB. And even though manual sharding is supported by most databases, MongoDB supports the concept of autosharding. This 15 minute high speed post provides a detailed overview of autosharding in MongoDB and, specifically, how to create shards supporting autosharding in MongoDB. The process of splitting up data and storing [...]]]></description>
			<content:encoded><![CDATA[<p>Scaling is a key feature of MongoDB.  And even though manual sharding is supported by most databases, MongoDB supports the concept of <em>autosharding</em>.  This 15 minute high speed post provides a detailed overview of autosharding in MongoDB and, specifically, how to create shards supporting autosharding in MongoDB.</p>
<p>The process of splitting up data and storing portions of data on different machines is called <em>sharding</em>.  By splitting up data across machines, it becomes possible to store more data and handle much more load without requiring large or powerful machines, e.g., machines that consist of powerful CPU&#8217;s and/or massive amounts of RAM.</p>
<p>Two types are sharding can occur.  <em>Manual sharding</em> and <em>autosharding</em>.</p>
<p>In <em>manual sharding</em>, the application code manages storing different data on different servers and querying the appropriate server to get it back.  Manual sharding can be done with virtually any database software package.</p>
<p>In MongoDB <em>autosharding</em>, some of the administrative overhead required in manual sharding is eliminated.  The cluster of database servers, or <em>shards</em>, handles splitting up of data and rebalancing of data automatically.</p>
<h2>Autosharding</h2>
<p>The basic concept behind MongoDB&#8217;s sharding is to break up collections into smaller chunks, or <em>documents</em>.  These documents can be distributed across shards so that each shard is responsible for a subset of the total dataset.</p>
<p>As an example, consider the following.  When you set up sharding you choose a key from a collection and use that key&#8217;s values to split up the data.  This key is called the <em>shard key</em>.</p>
<p>Suppose we had a collection of contacts.  If we chose &#8220;lastName&#8221; as our shard key, one shard could hold documents where &#8220;lastName&#8221; starts with A-F, the next shard could hold last names from G-P, and the final shard could hold last names Q-Z.  As you add or remove shards, MongoDB would rebalance this data so that each shard was getting a balanced amount of traffic and a practical amount of data.</p>
<p>So when should you decide to start sharding?  Consider the following reasons:</p>
<blockquote>
<ul>
<li>When you&#8217;ve run out of disk space on your current machine.</li>
<li>You want to write data faster than a single mongod can handle.</li>
<li>You want to keep a larger portion of data in memory to improve performance.</li>
</ul>
</blockquote>
<h2>Setting up Sharding</h2>
<p>Three different components are involved in sharding as follows:</p>
<h4>shard</h4>
<p style="padding-left: 30px;">A shard is a container that holds a subset of a collection&#8217;s data.  A shard is either a single mongod server (for development/testing), or a replica set (for production).</p>
<h4>mongos</h4>
<p style="padding-left: 30px;">This is the router process.  It routes requests and aggregates responses.  It doesn&#8217;t store any data or configuration information, although it does cache information from the config servers.</p>
<h4>config server</h4>
<p style="padding-left: 30px;">Config servers store the configuration of the cluster.  For example, which data is located on which shard.  Used by mongos to determine request routing.</p>
<h3>Starting the Servers</h3>
<p>First we need to strat up our config server and mongos.  We need to start a config server because mongos uses it to get its configuration.</p>
<pre class="brush: plain; title: ; notranslate">
$ mkdir -p ~/dbs/config
$ ./mongod --dbpath ~/dbs/config --port 20000
</pre>
<p>Now we start a mongos process for an application to connect to.  Routing servers do not even need a data directory, but they need to know the location of the config server.</p>
<pre class="brush: plain; title: ; notranslate">
$ ./mongos --port 30000 --configdb localhost:20000
</pre>
<p>Shard administration is always done through a mongos.</p>
<h3>Adding a Shard</h3>
<p>Start a normal mongod instance (or replica set), since this is what a shard naturally is</p>
<pre class="brush: plain; title: ; notranslate">
$ mkdir -p ~/dbs/shard1
$ ./mongod --dbpath ~/dbs/shard1 --port 10000
</pre>
<p>Now connect to the mongos process started earlier and add the shard to the cluster.</p>
<p>First, start up a shell connected to the mongos process as follows:</p>
<pre class="brush: plain; title: ; notranslate">
$ ./mongo localhost:30000/admin
</pre>
<p>Now add this shard with the <em><strong>addshard </strong></em>database command:</p>
<pre class="brush: plain; title: ; notranslate">
&gt; db.runCommand({addshard : &quot;localhost:10000&quot;, allowLocal : true})
{
    &quot;added&quot; : &quot;localhost:10000&quot;,
    &quot;ok&quot; : true
}
</pre>
<p>The &#8220;allowLocal&#8221; key is necessary only if you are running the shard on <strong>localhost </strong>and lets MongoDB know that you&#8217;re in development and know what you are doing.</p>
<h3>Sharding Data</h3>
<p>In order to allow MongoDB to distribute data, you have to explicitly turn sharding on at both the database and collection levels.  For example, the following enaables sharding for the database <em>acme</em>:</p>
<pre class="brush: plain; title: ; notranslate">
&gt; db.runCommand({&quot;enablesharding&quot; : &quot;acme&quot;})
</pre>
<p>Once you&#8217;ve enabled on the <em><strong>acme </strong></em>database, a collection is sharded by running the shardcollection command as follows:</p>
<pre class="brush: plain; title: ; notranslate">
&gt; db.runCommand({&quot;shardcollection&quot; : &quot;acme.products&quot;, &quot;key&quot;, : {&quot;_id&quot; : 1}})
</pre>
<p>Now the collection will be sharded by the &#8220;_id&#8221; key.  When data is added to <strong><em>acme</em></strong>, it will be automatically distributed across the shards based on the values of &#8220;_id&#8221;.</p>
<p>I hope this post enlightens you on the possibilities that MongoDB&#8217;s auto-sharding feature provides for ease of scaling.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.brianbuikema.com/2011/01/mongodb-sharding-a-detailed-overview-and-15-minute-high-speed-read/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Running MongoDB on Ubuntu: Overview, Installation, Setup, and Application Development using Python</title>
		<link>http://blog.brianbuikema.com/2011/01/mongodb-ubunto-overview-installation-setup-dev-python-2/</link>
		<comments>http://blog.brianbuikema.com/2011/01/mongodb-ubunto-overview-installation-setup-dev-python-2/#comments</comments>
		<pubDate>Wed, 26 Jan 2011 20:15:12 +0000</pubDate>
		<dc:creator>Brian Buikema</dc:creator>
				<category><![CDATA[Cloud Computing]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Document Repository]]></category>
		<category><![CDATA[Mongodb]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Ubunto]]></category>
		<category><![CDATA[cloudcomputing]]></category>
		<category><![CDATA[documentrepository]]></category>
		<category><![CDATA[nosql]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://blog.brianbuikema.com/?p=1234</guid>
		<description><![CDATA[MongoDb is becoming the defacto standard supporting the concept of NoSQL databases that are schemaless, and true document repositories. Companies developing state-of-the-art applications, both enterprise level and small start-ups, are embracing mongodb for its simple approach for supporting the development of schemaless databases that provide easy learning curve faster development than with traditional relational databases high availability [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.mongodb.org/" target="_blank">MongoDb</a> is becoming the defacto standard supporting the concept of NoSQL databases that are schemaless, and true document repositories. Companies developing state-of-the-art applications, both enterprise level and small start-ups, are embracing mongodb for its simple approach for supporting the development of schemaless databases that provide</p>
<ul>
<li>easy learning curve</li>
<li>faster development than with traditional <a href="http://en.wikipedia.org/wiki/Relational_database" target="_blank">relational databases</a></li>
<li>high availability and easy horizontal scalability</li>
<li>extremely fast access times</li>
<li>powerful indexing and querying capabilities, similar to its relational database counterparts</li>
<li>an ideal database platform for both <a href="http://en.wikipedia.org/wiki/Cloud_computing" target="_blank">cloud</a> and desktop computing</li>
<li>schemaless, document repositories, via collections and documents, that naturally fit application domains</li>
<li>an ideal database platform for embracing <a href="http://blog.brianbuikema.com/category/agile/" target="_blank">agile development</a></li>
</ul>
<p>A general set of MongoDB supported Use Cases, both <em>well suited</em> and <em>less well suited</em> are found <a href="http://www.mongodb.org/display/DOCS/Use+Cases" target="_blank">here</a>.</p>
<p>It should be noted that MongoDB shares the NoSQL spotlight with <a href="http://couchdb.apache.org/" target="_blank">CouchDB</a>.  Since MongoDB and CouchDB are both document-oriented databases with schemaless JSON-style object data storage, folks are naturally asking questions.  <a href="http://www.mongodb.org/display/DOCS/Comparing+Mongo+DB+and+Couch+DB" target="_blank">Please click here to compare MongoDB and CouchDB</a>.</p>
<h2>MongoDB Features</h2>
<p>Here is a list of MongoDB features.  Click on the links for details.</p>
<ul>
<li><a href="http://www.mongodb.org/display/DOCS/Schema+Design" target="_blank">Document-oriented storage</a> via <a href="http://bsonspec.org/" target="_blank">JSON-style documents</a> with dynamic schemas</li>
<li><a href="http://www.mongodb.org/display/DOCS/Indexes" target="_blank">Full Index Support</a></li>
<li><a href="http://www.mongodb.org/display/DOCS/Replication" target="_blank">Replication &amp; High Availability</a></li>
<li><a href="http://www.mongodb.org/display/DOCS/Sharding" target="_blank">Auto-Sharding</a></li>
<li><a href="http://www.mongodb.org/display/DOCS/Querying" target="_blank">Querying</a></li>
<li><a href="http://www.mongodb.org/display/DOCS/Updating" target="_blank">Fast In-Place Updates</a></li>
<li><a href="http://www.mongodb.org/display/DOCS/MapReduce" target="_blank">Map/Reduce</a></li>
<li><a href="http://www.mongodb.org/display/DOCS/GridFS" target="_blank">GridFS</a></li>
<li><a href="http://www.mongodb.org/display/DOCS/MongoDB+Commercial+Services+Providers" target="_blank">Commercial Support</a></li>
</ul>
<h2>The MongoDB Philosophy</h2>
<p>MongoDB was not created to be just another database that tries to do everything for everyone.</p>
<blockquote><p>Instead, MongoDB was created to work with <em>documents</em> rather than <em>rows</em>, was extremely fast, massively scalable, and easy to use.</p></blockquote>
<p>In order to accomplish this, some features were excluded, namely support for transactions.  Therefore, MongoDB may not be a great fit for developing accounting applications.  However, it is quite common to strategize software architectures by using a hybrid of technologies.  For example, a relational database works well with accounting and transactional components.  While MongoDB is a great technology for storing and retrieving complex data and document storage.</p>
<p>At a high-level, MongoDB provides the following (this is not an exhaustive list):</p>
<ul>
<li>A Rich Data Model</li>
<li>Easy Scaling</li>
<li>Simple Administration</li>
<li>Features such as <em>indexing</em>, <em>embedded document references</em>, <em>stored javascript</em>, <em>fixed-size collections</em>, <em>file storage</em>, <em>aggregation</em>, <em>replication</em>, <em>auto-sharding</em>, and more.</li>
<li>And all of the Above without Sacrificing Speed</li>
</ul>
<p>MongoDB is a document-oriented database.  It is not a relational one.  The primary reason for moving away from the relational model to the document-oriented model is to make scaling out easier, but additional advantages are found as well.</p>
<p>The fundamental idea is replacing the concept of a <em>row</em> with the more flexible model, the <em>document</em>.  By supporting embedded documents and arrays, the document-oriented approach makes it possible to represent complex hierarchical relationships with a single record.  This fits naturally with how data needs are addressed by developers using modern object-oriented languages.</p>
<p>More coming soon!</p>
<h2>Installing and Running MongoDB on Ubuntu</h2>
<p>I highly recommend installing MongoDB via the default repositories available in Ubuntu.  These repositories contain MongoDB, but may contain out-of-date versions.  Software installation from repositories is done through <em>aptitude</em>.  In order to obtain the latest versions of MongoDB, simply add the following line to your repository list found in <em><strong>/etc/apt/sources.list</strong></em></p>
<blockquote><p>deb http://downloads.mongodb.org/distros/ubuntu 10.4 10gen</p></blockquote>
<p>where 10.4 is the version of Ubuntu I run.  Make sure to supply the version of Ubuntu you run.</p>
<p>Next, you need to tell aptitude to retrieve the new repositories as follows:</p>
<pre class="brush: plain; title: ; notranslate">$ sudo aptitude update</pre>
<p>And now install MongoDB using the following command:</p>
<pre class="brush: plain; title: ; notranslate">$ sudo aptitude install mongodb-stable</pre>
<p>As the last step in the installation process, you will need to create the data directory yourself.  Make sure and do this as a non-root user.</p>
<pre class="brush: plain; title: ; notranslate">
$ sudo mkdir -p /data/db/
$ sudo chown `id -u` /data/db
</pre>
<p>You can start the MondoDB service as follows, and again, make sure and do this as a non-root user:</p>
<pre class="brush: plain; title: ; notranslate">
$ sudo start mongodb
$ sudo status mongodb
</pre>
<p>And start the MongoDB shell with the following command:</p>
<pre class="brush: plain; title: ; notranslate">$ mongo</pre>
<p>Once in the MongoDB shell, some basic commands include the following:</p>
<pre class="brush: plain; title: ; notranslate">
&amp;gt; show dbs
&amp;gt; show collections
&amp;gt; show users
&amp;gt; use &amp;lt;db name&amp;gt;
</pre>
<h3>Quick Reference to the MongoDB Upstart Scripts</h3>
<p>Here is a quick reference to the commands that control the execution of the mongod server process:</p>
<pre class="brush: plain; title: ; notranslate">
$ sudo status mongodb
$ sudo stop mongodb
$ sudo start mongodb
$ sudo restart mongodb
</pre>
<h3>Important in Case of Error Connecting to the Server</h3>
<p>If upon starting the MongoDB shell, you happen to get an error message connecting to the server similar to the following:</p>
<blockquote><p>Error: couldn&#8217;t connect to server 127.0.0.1} (anon):1137</p></blockquote>
<p>You may also notice that even though you issued the command to start the service, it actually did not start.  The next step is to verify that you are unable to start MongoDB.</p>
<p>Run <em>sudo start mongodb</em>.  It will report</p>
<blockquote><p><em>mongodb start/running, process XXXX</em></p></blockquote>
<p><em><strong> </strong></em>no matter what.  However, when you run <em>sudo status mongodb</em> again, you&#8217;ll get</p>
<blockquote><p>mongodb stop/waiting <span style="font-style: normal;">instead of</span> mongodb start/running</p></blockquote>
<p>Note:  This condition is largely due to an unclean shutdown, and results in the creation of a lockfile <em><strong>/var/lib/mongodb/mongod.lock</strong></em>.</p>
<p>The fix is a quick two-step process as follows:</p>
<ol>
<li>Remove the lockfile.</li>
<li>Run the repair script.</li>
</ol>
<p>This is accomplished as follows:</p>
<pre class="brush: plain; title: ; notranslate">
$ sudo rm /var/lib/mongodb/mongod.lock
$ sudo -u mongodb mongod -f /etc/mongodb.conf --repair
</pre>
<p>Now when you run <em>sudo start mongodb</em>.  It will report</p>
<blockquote><p>mongodb start/running, process XXXX</p></blockquote>
<p>and when you run <em>sudo status mongodb</em> again, you&#8217;ll get the expected</p>
<blockquote><p>mongodb start/running, process XXXX</p></blockquote>
<h3><span style="line-height: 28px; font-size: 26px;">Understanding Data Modeling under MongoDB</span></h3>
<p>A MongoDB database is non-relational and schemaless.  Therefore a MongoDB database is not bound to columns and data types like relational databases are.  One of the primary benefits of a flexible schemaless design is that you are not restricted when programming in a dynamically typed programming language such as Python.  Keep in mind that even though MongoDB is schemaless, the data structure is not completely devoid of schema as you still define collections and indexes, as we will discuss later.  Nevertheless you <em>will not need to predefine any data structure </em>for any of your documents you will be adding.</p>
<p>The fundamental components of a MongoDB database are <em>documents</em> and <em>collections</em>.</p>
<blockquote><p>Document is an item that contains the actual data, similar to a row in a SQL database table.</p></blockquote>
<blockquote><p>Collection is a collection of documents, similar to a table in a SQL database.  Unlike a SQL database, two or more completely different documents can co-exist in a single collection.</p></blockquote>
<p>More coming soon!</p>
<h2>Developing Applications under MongoDB using Python with Example Code</h2>
<p><a href="http://www.python.org/" target="_blank">Python</a> is a simple programming language that provides the natural ability to develop code that is perfectly readable.  Here are some links to Python code examples:</p>
<ul>
<li><a href="http://www.java2s.com/Code/Python/CatalogPython.htm" target="_blank">Catalog of Python Code Examples</a></li>
<li><a href="http://wiki.python.org/moin/SimplePrograms" target="_blank">Simple Python Programs</a></li>
</ul>
<p>In this section, we will develop simple, clear, and powerful code that works with MongoDB through the Python driver known as the <em><a href="https://github.com/mongodb/mongo-python-driver" target="_blank">PyMongo driver</a></em>.</p>
<h3>Installing the PyMongo Driver</h3>
<p>Before we begin to write Python code to access MongoDB databases, we first need to install the PyMongo driver.</p>
<p>I&#8217;m assuming you have Python 2.7 or greater up and running.  The steps for Python installation are simple once you obtain the source from <a href="http://python.org/download/" target="_blank">python.org/download</a> and extract the contents from the tar file, and are commonly listed as follows:</p>
<pre class="brush: plain; title: ; notranslate">
$ ./configure
$ make
$ make test
$ sudo make install
</pre>
<blockquote><p>Of course, you should always consult the readme file to obtain up-to-date instructions.</p></blockquote>
<p>The steps required to install the PyMongo driver are as follows:</p>
<h4><span style="font-weight: normal;">Step 1</span></h4>
<p style="padding-left: 30px;">Obtain the Python <em>setuptools</em> egg for your version of Python.  For example, I obtained setuptools-0.6c11-py2.7.egg from <a href="http://pypi.python.org/pypi/setuptools#using-setuptools-and-easyinstall" target="_blank">http://pypi.python.org/pypi/setuptools#using-setuptools-and-easyinstall</a>.</p>
<h4><span style="font-weight: normal;">Step 2</span></h4>
<p style="padding-left: 30px;">Now execute the downloaded egg as if it were an acual shell script by typing (<em>note your setuptools egg filename may be different depending on the version of Python you are using</em>).</p>
<pre class="brush: plain; title: ; notranslate">
$ sudo sh setuptools-0.6c11-py2.7.egg
</pre>
<h4><span style="font-weight: normal;">Step 3</span></h4>
<div style="padding-left: 30px;">Install the PyMongo module as follows:</div>
<pre class="brush: plain; title: ; notranslate">
$ sudo easy_install pymongo
</pre>
<p>That&#8217;s it!  But let&#8217;s test to ensure that our installation was a success.</p>
<p>From the Python shell, type the following:</p>
<pre class="brush: plain; title: ; notranslate">
&amp;gt;&amp;gt; import pymongo
</pre>
<p>You should be greeted with an empty cursor &gt;&gt;.  That&#8217;s success.</p>
<p>To take it one step further, we&#8217;ll insert data into a database and also retrieve it back.  Remember in MongoDB, if we try to retrieve a database that does not exist, MongoDB creates it for us automatically, as is the case with <strong><em>mytestdb</em></strong> below.</p>
<p>Type the following in the Python shell:</p>
<pre class="brush: plain; title: ; notranslate">
&amp;gt;&amp;gt; from pymongo import Connection
&amp;gt;&amp;gt; c = Connection()
&amp;gt;&amp;gt; db = c.mytestdb
&amp;gt;&amp;gt; collection = db.items
&amp;gt;&amp;gt; item = { &quot;Title&quot; : &quot;Test Data&quot;, &quot;Value1&quot; : &quot;1&quot;, &quot;Value2&quot; : &quot;2&quot;}
&amp;gt;&amp;gt; collection.insert(item)
&amp;gt;&amp;gt; collection.find_one()
</pre>
<div>The result of executing the last line, <em>collection.find_one()</em>, should result in the following (<em>note your ObjectId will probably be different</em>):</div>
<pre class="brush: plain; title: ; notranslate">
{u'_id': ObjectId('4d432adc1d41c85d8a000000'), u'Value1': u'1', u'Value2': u'2', u'Title': u'Test Data'}
</pre>
<h3>An Introduction to Working with MongoDB using Python via the PyMongo Driver</h3>
<p>Now that you have the PyMongo driver installed and running, it is time to learn the basics in developing Python code that works with MongoDB.</p>
<p>Instead of reinventing an already great tutorial, <a href="http://api.mongodb.org/python/1.4%2B/tutorial.html" target="_blank">I provide this link to the tutorial located on the mongodb.org site</a>.</p>
<p>Enjoy.</p>
<h2>Advanced:  Sharding</h2>
<p>Since <em>sharding </em>in MongoDB is a key feature and large topic to discuss, I created a <a href="http://blog.brianbuikema.com/2011/01/mongodb-sharding-a-detailed-overview-and-15-minute-high-speed-read/" target="_blank">separate post found here</a>.  This 15 minute high speed post provides a detailed overview of  autosharding in MongoDB and, specifically, how to create shards  supporting autosharding in MongoDB.</p>
<p>Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.brianbuikema.com/2011/01/mongodb-ubunto-overview-installation-setup-dev-python-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MS CRM Dynamics:  Part 2 &#8211; Adding High Performance Advanced Tuning and Optimizations to Your CRM System to Ensure Top Performance</title>
		<link>http://blog.brianbuikema.com/2010/12/ms-crm-dynamics-part-2-adding-high-performance-advanced-tuning-and-optimizations-to-your-crm-system-to-ensure-top-performance/</link>
		<comments>http://blog.brianbuikema.com/2010/12/ms-crm-dynamics-part-2-adding-high-performance-advanced-tuning-and-optimizations-to-your-crm-system-to-ensure-top-performance/#comments</comments>
		<pubDate>Sat, 04 Dec 2010 05:38:24 +0000</pubDate>
		<dc:creator>Brian Buikema</dc:creator>
				<category><![CDATA[Architecture & Design]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[CRM]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Enterprise]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://blog.brianbuikema.com/?p=1223</guid>
		<description><![CDATA[Part 1 discussed designing and executing advanced performance testing for the deployment of Microsoft CRM Dynamics solutions. This post discusses how to ensure your production CRM environment is tuned and optimized for top performance. My knowledge in this area has been largely obtained by working closely with Robert Shurtleff, the Microsoft CRM Dynamics Architect at [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.brianbuikema.com/2010/12/ms-crm-dynamics-part-1-designing-and-executing-advanced-performance-testing-of-your-crm-solution/">Part 1</a> discussed designing and executing advanced performance testing for the deployment of Microsoft CRM Dynamics solutions.</p>
<p>This post discusses how to ensure your production CRM environment is tuned and optimized for top performance.</p>
<p>My knowledge in this area has been largely obtained by working closely with Robert Shurtleff, the Microsoft CRM Dynamics Architect at Ciber.</p>
<p>Therefore I supply a link to <a href="http://rgsiiiya.blogspot.com/2010/11/dynamics-crm-advanced-performance.html">Robert&#8217;s post on this subject</a>.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.brianbuikema.com/2010/12/ms-crm-dynamics-part-2-adding-high-performance-advanced-tuning-and-optimizations-to-your-crm-system-to-ensure-top-performance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MS CRM Dynamics:  Part 1 &#8211; Designing and Executing Advanced Performance Testing of Your CRM Solution</title>
		<link>http://blog.brianbuikema.com/2010/12/ms-crm-dynamics-part-1-designing-and-executing-advanced-performance-testing-of-your-crm-solution/</link>
		<comments>http://blog.brianbuikema.com/2010/12/ms-crm-dynamics-part-1-designing-and-executing-advanced-performance-testing-of-your-crm-solution/#comments</comments>
		<pubDate>Sat, 04 Dec 2010 05:27:36 +0000</pubDate>
		<dc:creator>Brian Buikema</dc:creator>
				<category><![CDATA[Architecture & Design]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[CRM]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Enterprise]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://blog.brianbuikema.com/?p=1222</guid>
		<description><![CDATA[MS CRM Dynamics can be configured and customized per specific business needs. However, neglecting performance testing can kill your CRM deployment. Conversely, administering some common advanced performance tactics targeted at your specific usage can upgrade performance metrics to well above acceptable standards. More coming soon.]]></description>
			<content:encoded><![CDATA[<p>MS CRM Dynamics can be configured and customized per specific business needs.  However, neglecting performance testing can kill your CRM deployment.</p>
<p>Conversely, administering some common advanced performance tactics targeted at your specific usage can upgrade performance metrics to well above acceptable standards.</p>
<p>More coming soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.brianbuikema.com/2010/12/ms-crm-dynamics-part-1-designing-and-executing-advanced-performance-testing-of-your-crm-solution/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Solution to the Problem of Loading Sql Server 2008 Management Studio Express Edition on Windows 7</title>
		<link>http://blog.brianbuikema.com/2010/06/solution-to-the-problem-of-loading-sql-server-2008-management-studio-express-edition-on-windows-7/</link>
		<comments>http://blog.brianbuikema.com/2010/06/solution-to-the-problem-of-loading-sql-server-2008-management-studio-express-edition-on-windows-7/#comments</comments>
		<pubDate>Sat, 12 Jun 2010 07:10:16 +0000</pubDate>
		<dc:creator>Brian Buikema</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Lessons Learned]]></category>

		<guid isPermaLink="false">http://blog.brianbuikema.com/?p=776</guid>
		<description><![CDATA[I was up very, very late tonight installing apps on my laptop. What should have been 1-2 hours, drew out to 4+ hours. I kept having an issue attempting to install Sql Server 2008 Management Studio Express Edition immediately after installing Sql Server 2008 Express.  The error I received went something like This program has [...]]]></description>
			<content:encoded><![CDATA[<p>I was up very, very late tonight installing apps on my laptop.  What should have been 1-2 hours, drew out to 4+ hours.  I kept having an issue attempting to install Sql Server 2008 Management Studio Express Edition immediately after installing Sql Server 2008 Express.  The error I received went something like</p>
<blockquote><p>This program has known compatibility problems&#8230; check online to see if solutions are available from the Microsoft website&#8230;</p></blockquote>
<p>Well, I did find another <a href="https://www.microsoft.com/downloads/details.aspx?familyid=01AF61E6-2F63-4291-BCAD-FD500F6027FF&amp;displaylang=en" target="_blank">Sql Server 2008 Express Edition SP1 download link here</a>.  After learning this, I thought my life was looking up.  Yeah, right!</p>
<p>To get to the point, I Googled around a bit and <a href="http://goneale.com/2009/05/24/cant-install-microsoft-sql-server-2008-management-studio-express/" target="_blank">found this post</a> from someone who had the exact same problem as me.  After reading his post and some of his readers&#8217; comments, I determined I really should use the <a href="http://www.asp.net/downloads" target="_blank">Microsoft Web Platform Installer</a>.  It provides for the installation of many web development express versions, such as Sql Server 2008 Management Studio Express Edition, and even Silverlight.  And, best of all, <em>you don&#8217;t need to worry about the install order of dependent components</em>!</p>
<p>Worked like a charm!</p>
<p>As always, work smarter.  Not harder.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.brianbuikema.com/2010/06/solution-to-the-problem-of-loading-sql-server-2008-management-studio-express-edition-on-windows-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LINQ:  Doing Outer Joins (Example Included)</title>
		<link>http://blog.brianbuikema.com/2010/04/linq-doing-outer-joins-example-included/</link>
		<comments>http://blog.brianbuikema.com/2010/04/linq-doing-outer-joins-example-included/#comments</comments>
		<pubDate>Wed, 21 Apr 2010 03:21:31 +0000</pubDate>
		<dc:creator>Brian Buikema</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Lessons Learned]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[design patterns]]></category>
		<category><![CDATA[entity framework]]></category>
		<category><![CDATA[OOD]]></category>

		<guid isPermaLink="false">http://blog.brianbuikema.com/?p=438</guid>
		<description><![CDATA[I&#8217;m writing this post as a handy resource for those of us that need to reference a quick example of an outer join in LINQ.  I have found it time-consuming to find suitable examples elsewhere. My example is based on a simple Message entity that has a fishhook association to another Message entity.  The key [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m writing this post as a handy resource for those of us that need to reference a quick example of an outer join in <a href="http://msdn.microsoft.com/en-us/library/bb308959.aspx" target="_blank">LINQ</a>.  I have found it time-consuming to find suitable examples elsewhere.</p>
<p>My example is based on a simple Message entity that has a <em>fishhook </em>association to another Message entity.  The key here is that the relationship defines a 0..1 aggregation and <em>may associate to another Message entity, or not</em>.  When we query a list of Message entities we need to return <strong>all</strong> Message entities, including both</p>
<ul>
<li>those that contain associations to other Message entities, and</li>
<li>those that do not contain associations to other Message entities</li>
</ul>
<p>My entities are generated from the <a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;FamilyID=13fdfce4-7f92-438f-8058-b5b4041d0f01" target="_blank">Entity Framework</a>, and I use a DTO to return the actual data.  The context is established through a &#8220;BusinessEntities&#8221;object (as shown in line 3 below).  The outer join is demonstrated in lines 6 &#8211; 10 below.  Here is the code example:</p>
<pre class="brush: csharp; highlight: [3,6,7,8,9,10,30]; title: ; notranslate">
public IList&lt;DomainModel.Entities.DTOs.Message&gt; Messages(int recipientPartyId)
{
   var context = new BusinessEntities();
   IQueryable&lt;DomainModel.Entities.DTOs.Message&gt; entities =
   from m in context.Message
   let leftouter = (from msgRef in m.MessageReference
       select new
       {
           MsgRef = msgRef,
       }).FirstOrDefault()
   join recipient in context.Party on m.PartyRecipient.Id equals recipientPartyId
   where
       m.MessageStatusType.Id != MessageSendStatuses.Sent &amp;&amp;
       m.MessageStatusType.Id != MessageSendStatuses.Draft
   select new DomainModel.Entities.DTOs.Message
   {
       Id = m.Id,
       PartySenderId = m.PartySender.Id,
       SenderFirstName = m.PartySender.FirstName,
       SenderLastName = m.PartySender.LastName,
       PartyRecipientId = m.PartyRecipient.Id,
       RecipientFirstName = m.PartyRecipient.FirstName,
       RecipientLastName = m.PartyRecipient.LastName,
       Subject = m.Subject,
       Body = m.Message,
       SentAt = m.CreatedAt,
       MessageTypeId = m.MessageType.Id,
       MessageStatusTypeId = m.MessageStatusType.Id,
       MessageRecipientStatusTypeId = m.MessageRecipientStatusType.Id,
       MessageReference = leftouter.MsgRef != null ? new DomainModel.Entities.DTOs.Message(leftouter.MsgRef) : null
   };

   return entities.OrderByDescending(m =&gt; m.SentAt).ToList();
}
</pre>
<p>In line 30 above, if leftouter.MsgRef != null, we return an initialized Message DTO representing the associated Message entity.  Otherwise, leftouter.MgsRef == null, therefore we return null.</p>
<p>Hope this helps!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.brianbuikema.com/2010/04/linq-doing-outer-joins-example-included/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android:  Implement Paging to Manage User-Friendly List Views</title>
		<link>http://blog.brianbuikema.com/2010/04/android-implement-paging-to-manage-user-friendly-list-views/</link>
		<comments>http://blog.brianbuikema.com/2010/04/android-implement-paging-to-manage-user-friendly-list-views/#comments</comments>
		<pubDate>Sun, 04 Apr 2010 03:30:37 +0000</pubDate>
		<dc:creator>Brian Buikema</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Architecture & Design]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Enterprise]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[MVC]]></category>

		<guid isPermaLink="false">http://blog.brianbuikema.com/?p=352</guid>
		<description><![CDATA[Overview Every type of user interface needs a way to page through lists longer than a typical user interface can display in one screen.  Mobile platforms are no different, and in fact, may need this more than others.  Smartphones such as Droids, Palm Pre&#8217;s, Blackberrys, and iPhones contain small screens allowing for only a handful [...]]]></description>
			<content:encoded><![CDATA[<h2>Overview</h2>
<p>Every type of user interface needs a way to page through lists longer than a typical user interface can display in one screen.  Mobile platforms are no different, and in fact, may need this more than others.  Smartphones such as Droids, Palm Pre&#8217;s, Blackberrys, and iPhones contain small screens allowing for only a handful of list items to be displayed at once.  Some lists, such as your typical contacts list, reside directly on the device itself, and can be quickly navigated from front to back, and back to front again by a flick of your finger.  However, some lists, such as those residing in enterprise systems (and thus requiring over-the-network server requests), may be large enough to benefit from paging techniques when navigating those lists on a smartphone.  The reasons for paging are really no different for mobile clients than web pages.</p>
<p>In order to understand how to implement paging, the concept of paging must be understood.  Given a list of 50 items, and a page length of 10, we can break this list into 5 pages.  We commonly allow access to the pages through <em><strong>prev</strong></em>, <em><strong>next</strong></em>, and <em><strong>page number</strong></em> links.</p>
<p>Now let&#8217;s discuss the parameters required by the links to effectively execute paging.</p>
<p>A page is represented by the following criteria:</p>
<ul>
<li>Resource name or identifier</li>
<li>Page number</li>
<li>Page size</li>
</ul>
<p>The resource name or identifier is obvious.  If you plan on creating a service that implements paging, you must define the page number and page size.</p>
<h2>Example</h2>
<p>Let&#8217;s move on with creating an actual service that supports paging.  We will create our simple RESTful service in <a title="ASP.NET MVC" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=3b537c55-0948-4e6a-bf8c-aa1a78878da0&amp;displaylang=en" target="_blank">ASP.NET MVC</a>.  I will also provide this working service on my demo site (see actual service calls located after code).  Please note that we could easily use <a href="http://rubyonrails.org/" target="_blank">Rails</a>, <a href="http://www.grails.org/" target="_blank">Grails</a>, or other appropriate framework.</p>
<p>We create an EmployeesController that provides an <em>Index(&#8230;) </em>method.  The Index(&#8230;) method uses the parameters <em>page number</em> and <em>page size</em>.  If page number is null, we set it to 0 to indicate page 0.  This method calls the <em>retrieve</em>(&#8230;) method on the EmployeeRepository supplying the page number and page size parameters.</p>
<p>And lastly, the retrieve(&#8230;) method loads the employee records, using the LINQ extension methods <a title="Skip(...) and Take(...)" href="http://msdn.microsoft.com/en-us/library/bb386988.aspx" target="_blank"><em>Skip(&#8230;) </em>and </a><em><a title="Skip(...) and Take(...)" href="http://msdn.microsoft.com/en-us/library/bb386988.aspx" target="_blank">Take(&#8230;)</a> </em>to load the specific page requested.  Note that Skip(&#8230;) requires the number of records to skip, not number of pages.  So we use .Skip(pageNum * pageSize), as shown in line 43 below.</p>
<p>That&#8217;s it!  And here is the code demonstrating paging.</p>
<pre class="brush: csharp; highlight: [43]; title: ; notranslate">
namespace SOAServices.Controllers
{
    [WebApiEnabled]
    public class EmployeesController : Controller
    {
    //
    // GET: /Employees/

    public ActionResult Index(int? pageNum, int? pageSize)
    {
        pageNum = pageNum != null ? pageNum : 0;
        pageSize = pageSize != null ? pageSize : 5;
        IEmployeeRepository repository = new EmployeeRepository();

        return View(
            repository.Retrieve((int)pageNum, (int)pageSize)
            .AsSerializable&lt;Entities.DTOs.Employee&gt;());
        }
    }
}

namespace SOAServices.Models.Abstract
{
    public interface IEmployeeRepository
    {
        // define basic CRUD methods
        IList&lt;Entities.DTOs.Employee&gt; Retrieve(int pageNum, int pageSize);
        //Entities.DTOs.Employee Create();
        //Entities.DTOs.Employee Update(Entities.DTOs.Employee emp);
        //void Delete(int employeeId);
    }
}

namespace SOAServices.Models.Concrete
{
    public class EmployeeRepository : IEmployeeRepository
    {
       private EmployeeBusinessEntitiesDataContext _db = new EmployeeBusinessEntitiesDataContext(ConfigurationManager.ConnectionStrings[&quot;EmployeeDatabaseConnectionString&quot;].ConnectionString);
       public IList&lt;Entities.DTOs.Employee&gt; Retrieve(int pageNum, int pageSize)
       {
           var employees = _db.Employees
              .OrderBy(emp =&gt; emp.LastName + emp.FirstName)
              .Skip(pageNum * pageSize)
              .Take(pageSize)
              .Select(emp =&gt;
                new Entities.DTOs.Employee
                {
                  FirstName = emp.FirstName,
                  LastName = emp.LastName,
                  Email = emp.Email,
                  Title = emp.Title,
                  Phone = emp.Phone,
                  Id = emp.Id,
                  DeptId = emp.DeptId,
                  SalaryGradeId = emp.SalaryGradeId,
                  TakesLongLunches = emp.TakesLongLunches
                });
            return employees.ToList();
        }
    }
}

namespace SOAServices.Entities.DTOs
{
    [Serializable]
    [DataContract]
    public partial class Employee
    {
        [DataMember]
        public string FirstName { get; set; }
        [DataMember]
        public string LastName { get; set; }
        [DataMember]
        public string Email { get; set; }
        [DataMember]
        public string Phone { get; set; }
        [DataMember]
        public string Title { get; set; }
        [DataMember]
        public int Id { get; set; }
        [DataMember]
        public int DeptId { get; set; }
        [DataMember]
        public int SalaryGradeId { get; set; }
        [DataMember]
        public bool TakesLongLunches { get; set; }
    }
}
</pre>
<p>Let&#8217;s look at the real working code on my demo site.  We will use a page size of five and we will demonstrate using these <a href="http://demos.brianbuikema.com/apps/soa_services/employees" target="_blank">employee records</a>.</p>
<p>Pay special attention to the pageNum and pageSize url parameters as they specify the page to return.</p>
<p>Since the main topic of this post is to <em>support paging in Android</em> and our service is using the webapi declaration in ASP.NET MVC providing multiple serializable formats, we&#8217;ll first look at XML.</p>
<p><a href="http://demos.brianbuikema.com/apps/soa_services/employees?pageNum=0&amp;pageSize=5&amp;format=XML" target="_blank">Page 1</a>, <a href="http://demos.brianbuikema.com/apps/soa_services/employees?pageNum=1&amp;pageSize=5&amp;format=XML" target="_blank">Page 2</a>, <a href="http://demos.brianbuikema.com/apps/soa_services/employees?pageNum=2&amp;pageSize=5&amp;format=XML" target="_blank">Page 3</a></p>
<p>And now Json.</p>
<p><a href="http://demos.brianbuikema.com/apps/soa_services/employees?pageNum=0&amp;pageSize=5&amp;format=Json" target="_blank">Page 1</a>, <a href="http://demos.brianbuikema.com/apps/soa_services/employees?pageNum=1&amp;pageSize=5&amp;format=Json" target="_blank">Page 2</a>, <a href="http://demos.brianbuikema.com/apps/soa_services/employees?pageNum=2&amp;pageSize=5&amp;format=Json" target="_blank">Page 3</a></p>
<p>As you can see, it is very simple to support paging.  Next we will discuss how to work with <a href="http://developer.android.com/reference/android/widget/ListView.html" target="_blank">Android&#8217;s ListView</a> to support our new paging model.</p>
<p>More coming soon!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.brianbuikema.com/2010/04/android-implement-paging-to-manage-user-friendly-list-views/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
