<?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>Building Browsergames &#187; nosql</title>
	<atom:link href="http://buildingbrowsergames.com/tag/nosql/feed/" rel="self" type="application/rss+xml" />
	<link>http://buildingbrowsergames.com</link>
	<description>Ever wanted to build a browsergame?</description>
	<lastBuildDate>Mon, 29 Mar 2010 14:00:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>You should try a NoSQL database today.</title>
		<link>http://buildingbrowsergames.com/2010/02/01/you-should-try-a-nosql-database-today/</link>
		<comments>http://buildingbrowsergames.com/2010/02/01/you-should-try-a-nosql-database-today/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 14:00:08 +0000</pubDate>
		<dc:creator>Luke</dc:creator>
				<category><![CDATA[site-news]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[nosql]]></category>

		<guid isPermaLink="false">http://buildingbrowsergames.com/2010/02/01/you-should-try-a-nosql-database-today/</guid>
		<description><![CDATA[One of the hottest new web technologies being discussed right now on the web is NoSQL Databases &#8211; with the two I hear about most being CouchDB and MongoDB.
NoSQL databases provide a different approach than traditional relational databases by being &#8217;schema-less&#8217; &#8211; allowing you to quickly and easily add arbitrary data to whatever you need [...]]]></description>
			<content:encoded><![CDATA[<p>One of the hottest new web technologies being discussed right now on the web is <a href='http://nosql-database.org/'>NoSQL Databases</a> &#8211; with the two I hear about most being <a href='http://couchdb.apache.org/'>CouchDB</a> and <a href='http://www.mongodb.org/display/DOCS/Home'>MongoDB</a>.</p>
<p>NoSQL databases provide a different approach than traditional relational databases by being &#8217;schema-less&#8217; &#8211; allowing you to quickly and easily add arbitrary data to whatever you need to. This is a feature that&#8217;s <strong>extremely</strong> well-suited to browsergames &#8211; if you need a certain item to have a specific attribute that no other item has, it&#8217;s easy: you just add it, and move on. In a traditional SQL-based database setup, you&#8217;d need to add a column and make sure it was null or defaulted for all of your other items &#8211; which would be a major hassle if you had a large number of items.</p>
<p>Both the <a href='http://couchdb.apache.org'>CouchDB</a> and <a href='http://mongodb.org/display/DOCS/Home'>MongoDB</a> sites have quickstart guides &#8211; if you haven&#8217;t tried one of the two out already, I highly encourage you to do so.</p>
<ul>
<li><a href='http://wiki.apache.org/couchdb/Basics'>CouchDB Quickstart</a></li>
<li><a href='http://www.mongodb.org/display/DOCS/Quickstart'>MongoDB Quickstart</a></li>
</ul>
<p>If you still need some convincing, here are a few areas in a game where a NoSQL database like Couch or Mongo will be better-suited than a traditional database like MySQL or PostgreSQL:</p>
<ul>
<li>
<h2>Items</h2>
<p>So you have a potion, and potions usually heal people. But for this one super-rare potion, you want to heal the player <strong>and</strong> teleport them to a secret location. How?</p>
<p>In a traditional SQL-based system, you&#8217;d add a column to your <em>items</em> table to track what the potion did, and then add the extra code and handlers so that when a potion of the one super-rare type was used, the player was both healed and teleported. This works, but it&#8217;s a bit of a pain &#8211; you need to create/track a new item type, along with writing the code to handle it.</p>
<p>In a schema-less situation (when you&#8217;re using something like Couch or Mongo), all you have to do is add an attribute &#8216;teleports_player_to&#8217; to your item &#8211; and then in your code, check if the item has a &#8216;teleports_player_to&#8217; attribute. If it does, teleport the player there after running your item handling code. All done!</p>
</li>
<li>
<h2>Quests</h2>
<p>Quests are one area where schema-less storage really shines. You want to keep track of quests a player is on &#8211; but each quest is different! One quest involves killing a certain number of enemies, while another requires you to talk to two different NPC&#8217;s, while yet another needs you to move Important Package A to Secret Location B. How do you track all of that data?</p>
<p>In a relational database, you do it by keeping track of what &#8216;type&#8217; each quest is, along with a small amount of arbitrary information related to that quest. For a &#8220;kill 10 ogres&#8221; quest, you need to track that it&#8217;s a killing quest, you need 10 things killed, and those &#8216;things&#8217; are, in this case, ogres. For a &#8220;delivery&#8221; quest, you need to track which item the player has to have, and which location they need to take it to.</p>
<p>In situations like this, using a relational database to track information for your quests starts to break down very rapidly. What if you wanted to have a quest that required a player to kill 10 ogres, and <strong>then</strong> deliver a package to the town mayor? How would you do that?</p>
<p>With a schema-less database, this is easy. All you have to do is check which attributes you quest has, and write your code to work around them &#8211; so if you wanted to have a quest where users had to kill 28 goblins, talk to the goblin herder and the shepherd, and then deliver the goblin herder&#8217;s letter of surrender to the shepherd, you could &#8211; all you&#8217;d have to do is check the quest attributes.</p>
</li>
</ul>
<p>What other situations can you come up with when a NoSQL database might be superior to using a relational database to track data in your game, or when a relational database is a better option? Let us know in the comments!</p>
]]></content:encoded>
			<wfw:commentRss>http://buildingbrowsergames.com/2010/02/01/you-should-try-a-nosql-database-today/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

