<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Database Land</title>
	<atom:link href="http://dbland.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://dbland.wordpress.com</link>
	<description>where data lives in peace and harmony (or in rows and columns)</description>
	<lastBuildDate>Wed, 02 Mar 2011 22:20:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='dbland.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Database Land</title>
		<link>http://dbland.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://dbland.wordpress.com/osd.xml" title="Database Land" />
	<atom:link rel='hub' href='http://dbland.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Query Optimization</title>
		<link>http://dbland.wordpress.com/2011/02/26/query-optimization/</link>
		<comments>http://dbland.wordpress.com/2011/02/26/query-optimization/#comments</comments>
		<pubDate>Sun, 27 Feb 2011 00:29:21 +0000</pubDate>
		<dc:creator>Amr El-Helw</dc:creator>
				<category><![CDATA[Query Processing]]></category>
		<category><![CDATA[statistics]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[plan]]></category>
		<category><![CDATA[cost]]></category>

		<guid isPermaLink="false">http://dbland.wordpress.com/?p=76</guid>
		<description><![CDATA[This article gives a very simplified overview on query optimization. For more information, see: Query optimizer [Wikipedia]. The query optimizer is arguably the most important module in a DBMS. The job of the optimizer is to find the best way of executing a given query. The most common type of query optimization is cost-based query [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dbland.wordpress.com&amp;blog=2215096&amp;post=76&amp;subd=dbland&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><em>This article gives a very simplified overview on query optimization. For more information, see: <a href="http://en.wikipedia.org/wiki/Query_optimizer" target="_blank">Query optimizer [Wikipedia]</a>.</em></p>
<p>The query optimizer is arguably the most important module in a DBMS. The job of the optimizer is to find the best way of executing a given query. The most common type of query optimization is <em>cost-based</em> query optimization, in which the optimizer tries to find the <em>cheapest</em> execution plan based on a pre-defined <em>cost model</em>. The cost model defines how to estimate the cost of each query operator based on its input and output cardinalities, as well as the available system resources (CPU, memory, etc.)</p>
<p>In cost-based query optimization, the optimizer estimates the cost of each query plan using information and statistics about the underlying data. These statistics exist in the <a href="http://dbland.wordpress.com/2008/01/22/database-catalog/">database catalog</a>. Based on these estimated costs, the optimizer then chooses the plan with the least estimated cost, and returns this plan to be used by the execution engine.</p>
<p>Cost-based optimizers work by breaking down a query into smaller <em>logical expressions</em>. A logical expression of size <em>n</em> is an expression involving <em>n</em> base tables. First the optimizer starts by estimating the cost of logical expressions of size 1. The cost of these expressions is usually estimated using the statistics available about the base tables. For each expression, the optimizer enumerates all possible execution plans that can be used to evaluate such expression, estimates the cost of each of these plans, then keeps only the cheapest plan for such expression*. </p>
<p>Next, the optimizer starts to work on expressions of size 2. The cost of these expressions is estimated based on the cost of the expressions of size 1. Again, for each expression, the optimizer enumerates all possible plans for that expression (using different <em>join methods</em> and <em>join orders</em>, etc.), estimates the cost of each plan, and keeps the cheapest plan. This continues for logical expressions of increasing sizes until the optimizer has the cheapest plan for the whole query.</p>
<p><em>* This is actually a simplification. In reality, the optimizer maintains several plans with different properties for each expression. For example: the cheapest plan overall, the cheapest plan that gives sorted output, the cheapest non-blocking plan (the one that gives the first output tuple as fast as possible), etc.</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dbland.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dbland.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dbland.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dbland.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dbland.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dbland.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dbland.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dbland.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dbland.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dbland.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dbland.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dbland.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dbland.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dbland.wordpress.com/76/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dbland.wordpress.com&amp;blog=2215096&amp;post=76&amp;subd=dbland&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dbland.wordpress.com/2011/02/26/query-optimization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f4ee5f8a4265aa2318eda20cde661f83?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">aelhelw</media:title>
		</media:content>
	</item>
		<item>
		<title>Database Land is back!</title>
		<link>http://dbland.wordpress.com/2011/02/22/database-land-is-back/</link>
		<comments>http://dbland.wordpress.com/2011/02/22/database-land-is-back/#comments</comments>
		<pubDate>Tue, 22 Feb 2011 20:03:36 +0000</pubDate>
		<dc:creator>Amr El-Helw</dc:creator>
				<category><![CDATA[Announcements]]></category>

		<guid isPermaLink="false">http://dbland.wordpress.com/?p=38</guid>
		<description><![CDATA[I apologize for the long wait, but after a long time off, I&#8217;m glad to announce that this blog is up and running once again. The design has been revamped, and I will continue to write on topics related to databases and information technology. Stay tuned, and happy reading!!<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dbland.wordpress.com&amp;blog=2215096&amp;post=38&amp;subd=dbland&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I apologize for the long wait, but after a long time off, I&#8217;m glad to announce that this blog is up and running once again. The design has been revamped, and I will continue to write on topics related to databases and information technology.</p>
<p>Stay tuned, and happy reading!!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dbland.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dbland.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dbland.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dbland.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dbland.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dbland.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dbland.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dbland.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dbland.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dbland.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dbland.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dbland.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dbland.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dbland.wordpress.com/38/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dbland.wordpress.com&amp;blog=2215096&amp;post=38&amp;subd=dbland&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dbland.wordpress.com/2011/02/22/database-land-is-back/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f4ee5f8a4265aa2318eda20cde661f83?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">aelhelw</media:title>
		</media:content>
	</item>
		<item>
		<title>Materialized Views</title>
		<link>http://dbland.wordpress.com/2008/12/09/materialized-views/</link>
		<comments>http://dbland.wordpress.com/2008/12/09/materialized-views/#comments</comments>
		<pubDate>Tue, 09 Dec 2008 17:44:09 +0000</pubDate>
		<dc:creator>Amr El-Helw</dc:creator>
				<category><![CDATA[Database Objects]]></category>
		<category><![CDATA[materialized]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[tables]]></category>
		<category><![CDATA[views]]></category>

		<guid isPermaLink="false">http://dbland.wordpress.com/?p=27</guid>
		<description><![CDATA[A materialized view is a variation of the regular database view. Both are results of database queries. The regular (non-materialized) view is only logically stored in the database (i.e. the contents are not physically stored, but dynamically computed whenever needed). On the other hand, the results of the materialized view are physically stored as a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dbland.wordpress.com&amp;blog=2215096&amp;post=27&amp;subd=dbland&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A materialized view is a variation of the regular <a href="http://dbland.wordpress.com/2008/08/05/database-views/">database view</a>. Both are results of database queries. The regular (non-materialized) view is only logically stored in the database (i.e. the contents are not physically stored, but dynamically computed whenever needed). On the other hand, the results of the materialized view are physically stored as a concrete table in the database, and are retrieved directly when referenced.</p>
<p>Since materialized views are physically stored, they may become inconsistent with their original data sources (when the data sources change due to updates). For this reason, materialized views have to be periodically updated to account for changes in the <a href="http://dbland.wordpress.com/2007/12/09/database-tables/">base tables</a>. This is not an issue with non-materialized views, since they are re-computed from the original data every time they are referenced.</p>
<p>Therefore, materialized views allow much more efficient access (since they do not have to be re-computed all the time), at the cost of some data being possibly out-of-date. They are most useful in data warehousing scenarios, where the base tables are not updated very often, and frequent queries of the actual base tables can be extremely expensive.</p>
<p>Materialized views can be used exactly in the same way as regular views. They can be used to simplify queries, and hide their details, or to store common computations that are referenced by multiple queries.</p>
<p>However, they have one additional use that is the quite the opposite of regular views. Recall that during <a href="http://dbland.wordpress.com/2008/02/14/the-basics-vi-overview-on-query-processing/">query processing</a>, queries that reference views are usually rewritten to reference the base tables. However, the <a href="http://dbland.wordpress.com/2011/02/26/query-optimization/">query optimizer</a> tries to reuse materialized views to evaluate queries. This is known as <em>materialized view matching and utilization</em>. Since the contents of these materialized views are already precomputed, using them for query evaluation can result in a significant performance improvement.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dbland.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dbland.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dbland.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dbland.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dbland.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dbland.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dbland.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dbland.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dbland.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dbland.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dbland.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dbland.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dbland.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dbland.wordpress.com/27/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dbland.wordpress.com&amp;blog=2215096&amp;post=27&amp;subd=dbland&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dbland.wordpress.com/2008/12/09/materialized-views/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f4ee5f8a4265aa2318eda20cde661f83?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">aelhelw</media:title>
		</media:content>
	</item>
		<item>
		<title>Database Views</title>
		<link>http://dbland.wordpress.com/2008/08/05/database-views/</link>
		<comments>http://dbland.wordpress.com/2008/08/05/database-views/#comments</comments>
		<pubDate>Tue, 05 Aug 2008 15:11:06 +0000</pubDate>
		<dc:creator>Amr El-Helw</dc:creator>
				<category><![CDATA[Database Objects]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[rewrite]]></category>
		<category><![CDATA[tables]]></category>
		<category><![CDATA[views]]></category>

		<guid isPermaLink="false">http://dbland.wordpress.com/?p=18</guid>
		<description><![CDATA[A database view is a stored query accessible as a virtual table. The contents of this virtual table are the results of that query. Views are only logically stored in the database (i.e. the contents are not physically stored, but dynamically computed whenever needed). Materialized views are an exception to this rule. Changing the data [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dbland.wordpress.com&amp;blog=2215096&amp;post=18&amp;subd=dbland&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A database view is a stored query accessible as a virtual table. The contents of this virtual table are the results of that query. Views are only logically stored in the database (i.e. the contents are not physically stored, but dynamically computed whenever needed). <a href="http://dbland.wordpress.com/2008/12/09/materialized-views/">Materialized views</a> are an exception to this rule. Changing the data in a <a href="http://dbland.wordpress.com/2007/12/09/database-tables/">base table</a> automatically alters any view that references that table.</p>
<p>A view can be used in exactly the same way as a base table. Views can be used for the following reasons:</p>
<ul>
<li>Simplify queries by creating views to represnts parts of these queries</li>
<li>Hiding the complexity of the data, by creating views that reflect on the parts of the data relevant to a particular user</li>
<li>Providing extra security by giving users access only to the views, not to the base tables, thus restricting the data they can access</li>
<li>Since the actual contents of the views are not physically stored, they do not require much space</li>
</ul>
<p>Views can be seen in analogy to modules (or functions) in programming. They can be used to create abstraction. They can be nested (a query can reference a view, and a view can reference other views, etc.)</p>
<p>For example, consider the following two queries:</p>
<table border="0">
<tbody>
<tr>
<td><strong>Query 1:</strong></td>
<td></td>
<td><strong>Query 2:</strong></td>
</tr>
<tr>
<td><code>SELECT name, balance<br />
FROM (SELECT name, money_received, money_sent,<br />
(money_received - money_sent) AS balance, address<br />
FROM table_customers c, accounts_table a<br />
WHERE a.customerid = c.customer_id<br />
)<br />
WHERE money_sent &gt; 10000</code></td>
<td></td>
<td><code>SELECT name, address<br />
FROM (SELECT name, money_received, money_sent,<br />
(money_received - money_sent) AS balance, address<br />
FROM table_customers c, accounts_table a<br />
WHERE a.customerid = c.customer_id<br />
)<br />
WHERE balance between 10000 and 20000</code></td>
</tr>
</tbody>
</table>
<p>Both these queries contain the same sub-query. To simplify these queries, it is possible to define a view (<em>v_cust_account</em>) as follows:</p>
<p><code>CREATE VIEW v_cust_account AS<br />
SELECT name, money_received, money_sent,<br />
(money_received - money_sent) AS balance, address<br />
FROM table_customers c, accounts_table a<br />
WHERE a.customerid = c.customer_id<br />
</code></p>
<p>Now this view can be treated as a table containing the results of the subquery. Now the 2 initial queries can be simplified as follows:</p>
<table border="0">
<tbody>
<tr>
<td><strong>Query 1a:</strong></td>
<td></td>
<td><strong>Query 2a:</strong></td>
</tr>
<tr>
<td><code>SELECT name, balance<br />
FROM v_cust_account<br />
WHERE money_sent &gt; 10000</code></td>
<td></td>
<td><code>SELECT name, address<br />
FROM v_cust_account<br />
WHERE balance between 10000 and 20000</code></td>
</tr>
</tbody>
</table>
<p>Views are usually read-only, i.e. one cannot directly update the data in a view, but can only update the underlying tables. However, in some cases, a view can be updatable, but only if the database system is able to determine the reverse mapping from the view schema to the schema of the underlying base tables. In this case, <strong>INSERT</strong>, <strong>UPDATE</strong>, and <strong>DELETE</strong> operations can be performed. Read-only views do not support such operations because the DBMS is not able to map the changes to the underlying base tables.</p>
<p>During <a href="http://dbland.wordpress.com/2008/02/14/the-basics-vi-overview-on-query-processing/">query processing</a>, queries that reference views are usually rewritten to reference the base tables. For example, if a user issues <strong>Query 1a</strong> to the DBMS, the query processor will determine that the query references the view (<strong>v_cust_account</strong>). It will then proceed to rewrite this query to reference the base tables (thus it will look like the original query (<strong>Query 1</strong>).</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dbland.wordpress.com/18/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dbland.wordpress.com/18/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dbland.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dbland.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dbland.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dbland.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dbland.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dbland.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dbland.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dbland.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dbland.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dbland.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dbland.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dbland.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dbland.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dbland.wordpress.com/18/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dbland.wordpress.com&amp;blog=2215096&amp;post=18&amp;subd=dbland&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dbland.wordpress.com/2008/08/05/database-views/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f4ee5f8a4265aa2318eda20cde661f83?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">aelhelw</media:title>
		</media:content>
	</item>
		<item>
		<title>The Basics (VI) &#8211; Overview on Query Processing</title>
		<link>http://dbland.wordpress.com/2008/02/14/the-basics-vi-overview-on-query-processing/</link>
		<comments>http://dbland.wordpress.com/2008/02/14/the-basics-vi-overview-on-query-processing/#comments</comments>
		<pubDate>Thu, 14 Feb 2008 19:20:28 +0000</pubDate>
		<dc:creator>Amr El-Helw</dc:creator>
				<category><![CDATA[Basics]]></category>
		<category><![CDATA[Query Processing]]></category>
		<category><![CDATA[catalog]]></category>
		<category><![CDATA[cost]]></category>
		<category><![CDATA[execution]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[plan]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[rewrite]]></category>
		<category><![CDATA[semantic]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://dbland.wordpress.com/?p=13</guid>
		<description><![CDATA[I mentioned before that SQL is a declarative language, where the user only specifies WHAT they want to get from the database, not HOW to get it. The how part is the responsibility of the database engine. Query processing is a complex task that involves several steps in order to translate a user&#8217;s query to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dbland.wordpress.com&amp;blog=2215096&amp;post=13&amp;subd=dbland&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I mentioned before that <a href="http://dbland.wordpress.com/2008/02/03/the-basics-v-database-queries-sql/">SQL</a> is a declarative language, where the user only specifies <em>WHAT</em> they want to get from the database, not <em>HOW</em> to get it. The <em>how</em> part is the responsibility of the database engine. Query processing is a complex task that involves several steps in order to translate a user&#8217;s query to something that the computer can actually execute in order to retrieve the results of that query.</p>
<p>Query processing usually consists of the following phases:</p>
<ol>
<li><strong>Parsing</strong><br />
In this phase, the engine analyzes the <em>text</em> of the SQL query, to make sure that it is written correctly, and reports any syntax errors (misspellings, unidentified operators, etc.). If the query has no errors, it is translated into an internal representation that is to be used for later processing.</li>
<li><strong>Semantic Checking</strong><br />
Now that the text of the query has no errors, the <em>semantics</em> are checked. The engine makes sure that any referenced tables, columns, or views are valid. This phase is sometimes considered part of the parsing phase.</li>
<li><strong>Query Rewrite</strong><br />
First of all, note that usually the same query may have multiple representations in SQL. Complex queries often result in redundancy, especially with <a href="http://dbland.wordpress.com/2008/08/05/database-views/">views</a>. The Query rewriting phase rewrites a given SQL query into another query that is equivalent (produces the same result), but may be processed more efficiently.</li>
<li><strong>Query Optimization</strong><br />
This is probably the most important phase in query processing, in which the engine tries to figure out the best way to evaluate the query (the &#8220;<em>how</em>&#8221; part). The same query can usually be evaluated in multiple ways, depending on which tables are joined first, what join methods are used, whether the predicates are tested at the beginning or at the end, etc. Each such way is called a <a href="http://en.wikipedia.org/wiki/Query_plan" target="_blank">query execution plan</a> (or just a query plan). For the same query, some plans are more efficient than others. The job of the <a href="http://dbland.wordpress.com/2011/02/26/query-optimization/" target="_blank">query optimizer</a> is:</p>
<ol>
<li>Determine all possible query plans for the query in hand</li>
<li>Estimate the execution cost for each of these plans. This is achieved using the statistics available in the <a href="http://dbland.wordpress.com/2008/01/22/database-catalog/">database catalog</a></li>
<li>Pick the plan with the least estimated cost</li>
</ol>
</li>
<li><strong>Code Generation</strong><br />
Once a query plan is chosen, the system translates this plan into executable machine code.</li>
<li><strong>Plan Execution</strong><br />
Finally the query is executed, and the results are returned.</li>
</ol>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dbland.wordpress.com/13/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dbland.wordpress.com/13/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dbland.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dbland.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dbland.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dbland.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dbland.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dbland.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dbland.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dbland.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dbland.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dbland.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dbland.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dbland.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dbland.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dbland.wordpress.com/13/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dbland.wordpress.com&amp;blog=2215096&amp;post=13&amp;subd=dbland&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dbland.wordpress.com/2008/02/14/the-basics-vi-overview-on-query-processing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f4ee5f8a4265aa2318eda20cde661f83?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">aelhelw</media:title>
		</media:content>
	</item>
		<item>
		<title>The Basics (V) &#8211; Database Queries &amp; SQL</title>
		<link>http://dbland.wordpress.com/2008/02/03/the-basics-v-database-queries-sql/</link>
		<comments>http://dbland.wordpress.com/2008/02/03/the-basics-v-database-queries-sql/#comments</comments>
		<pubDate>Sun, 03 Feb 2008 22:59:40 +0000</pubDate>
		<dc:creator>Amr El-Helw</dc:creator>
				<category><![CDATA[Basics]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://dbland.wordpress.com/?p=12</guid>
		<description><![CDATA[So far, we have talked about the data being arranged nicely into tables, with relationships between these tables that represent the relationships between the real life objects they represent. We even have information about these tables stored in the database catalog. So, now what?? The real advantage of a database system is not its ability [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dbland.wordpress.com&amp;blog=2215096&amp;post=12&amp;subd=dbland&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So far, we have talked about the data being arranged nicely into <a href="http://dbland.wordpress.com/2007/12/09/database-tables/">tables</a>, with <a href="http://dbland.wordpress.com/2007/12/21/foreign-keys-referential-integrity/">relationships between these tables</a> that represent the relationships between the real life objects they represent. We even have information about these tables stored in the <a href="http://dbland.wordpress.com/2008/01/22/database-catalog/">database catalog</a>. So, now what??</p>
<p>The real advantage of a database system is not its ability to store the data in an organized format. If we have huge amounts of data that we only need to store, then we can just dump it into huge text files. Actually, we might as well just leave all the data in huge paper files tucked into an old dusty archive room. After all, the data will just be sitting there. But let&#8217;s say, for some reason, I want to check how many projects have been completed by the XYZ department in the year 2005, with only 5 employees or less working on each project. I think it will be hard to go through all those files to figure out the answer to that.</p>
<p>That&#8217;s where databases make our life easier. The real advantage of using a database is not just <i>storing</i> the data, but also being able to <i>query</i> the data&#8230;efficiently. Think of a database query as a question. The user asks the database a question, and the database returns the result. Database queries can be as simple or as complex as required.</p>
<p>In order to standardize the way databases are queries, <b>SQL (Structured Query Language)</b> was invented. <a href="http://en.wikipedia.org/wiki/SQL" target="_blank">SQL</a> is a standard way of formulating a query that can be understood be any database system (except from some system-specific features that are not part of the standard SQL). SQL is considered a <i>declarative</i> language, not a <i>procedural</i> language. This means that the user only specifies <i>WHAT</i> they want, not <i>HOW</i> to get it. For example, the following simple SQL query asks the database to retrieve the names of all employees who work in the Sales department since before 2001:</p>
<p><b>SELECT name<br />
FROM employee<br />
WHERE dept_name = &#8216;Sales&#8217;<br />
AND hire_year &lt; 2001</b></p>
<p>SQL can also be used to insert or update the data in the database. We are not going to get into the details of SQL here, but a good introduction to SQL can be found <a href="http://www.w3schools.com/sql/default.asp" target="_blank">here</a>.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dbland.wordpress.com/12/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dbland.wordpress.com/12/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dbland.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dbland.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dbland.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dbland.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dbland.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dbland.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dbland.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dbland.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dbland.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dbland.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dbland.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dbland.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dbland.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dbland.wordpress.com/12/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dbland.wordpress.com&amp;blog=2215096&amp;post=12&amp;subd=dbland&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dbland.wordpress.com/2008/02/03/the-basics-v-database-queries-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f4ee5f8a4265aa2318eda20cde661f83?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">aelhelw</media:title>
		</media:content>
	</item>
		<item>
		<title>The Basics (IV) &#8211; Database Catalog</title>
		<link>http://dbland.wordpress.com/2008/01/22/database-catalog/</link>
		<comments>http://dbland.wordpress.com/2008/01/22/database-catalog/#comments</comments>
		<pubDate>Tue, 22 Jan 2008 15:45:15 +0000</pubDate>
		<dc:creator>Amr El-Helw</dc:creator>
				<category><![CDATA[Basics]]></category>
		<category><![CDATA[catalog]]></category>
		<category><![CDATA[statistics]]></category>

		<guid isPermaLink="false">http://dbland.wordpress.com/2008/01/22/database-catalog/</guid>
		<description><![CDATA[The database catalog of a database is a repository of information (or meta data) about the various objects in the database, such as tables, views, indexes, users, etc. The information in the catalog is used by the database system when processing any of these objects. For example, the information about a database table would include [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dbland.wordpress.com&amp;blog=2215096&amp;post=11&amp;subd=dbland&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The database catalog of a database is a repository of information (or meta data) about the various objects in the database, such as <a href="http://dbland.wordpress.com/2007/12/09/database-tables/">tables</a>, views, indexes, users, etc. The information in the catalog is used by the database system when processing any of these objects.</p>
<p>For example, the information about a <a href="http://dbland.wordpress.com/2007/12/09/database-tables/">database table</a> would include the definition of the table (i.e. the names of the columns, the data types, the primary key, and any foreign keys in that table), as well as statistics on the data stored in that table. These statistics include the number of tuples in that table, the number of physical data pages that the table occupies on disk, the user who owns the table. It also includes statistics about each column in that table, for example: the highest and lowest values in the column, the number of distinct values in the column, and possibly the distribution of data values in the column (usually in the form of a histogram). In addition to statistics about single columns, sometimes statistics are also maintained about groups of columns. For example, similar to keeping the number of distinct values, the catalog might contain the number of distinct value combinations in a group of columns. This can be useful in query processing.</p>
<p>Note that the database catalog is itself a set of tables. The information in the catalog can usually be accessed in the same way as the information in any other table, but usually only for viewing, not for update. Updating the catalog manually can cause serious inconsistencies in the database which can cause the database system to be unusable. For example, imagine if a user can manually update the catalog and change the definition of a table. In this case, the table definition would not match the data already stored in it, thus the data will be lost. For this reason, manual updates of the catalog are not permitted, and must only be done through specific commands.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dbland.wordpress.com/11/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dbland.wordpress.com/11/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dbland.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dbland.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dbland.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dbland.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dbland.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dbland.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dbland.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dbland.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dbland.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dbland.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dbland.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dbland.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dbland.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dbland.wordpress.com/11/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dbland.wordpress.com&amp;blog=2215096&amp;post=11&amp;subd=dbland&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dbland.wordpress.com/2008/01/22/database-catalog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f4ee5f8a4265aa2318eda20cde661f83?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">aelhelw</media:title>
		</media:content>
	</item>
		<item>
		<title>The Basics (III) &#8211; Foreign Keys &amp; Referential Integrity</title>
		<link>http://dbland.wordpress.com/2007/12/21/foreign-keys-referential-integrity/</link>
		<comments>http://dbland.wordpress.com/2007/12/21/foreign-keys-referential-integrity/#comments</comments>
		<pubDate>Fri, 21 Dec 2007 20:01:11 +0000</pubDate>
		<dc:creator>Amr El-Helw</dc:creator>
				<category><![CDATA[Basics]]></category>
		<category><![CDATA[attributes]]></category>
		<category><![CDATA[foreign key]]></category>
		<category><![CDATA[referential integrity]]></category>

		<guid isPermaLink="false">http://dbland.wordpress.com/2007/12/21/foreign-keys-referential-integrity/</guid>
		<description><![CDATA[As we already discussed, a database table stores the information that is related to a specific entity type. Different entities are stored in different tables, with each table having its own structure, and own attributes related to that entity. In most situations, the entities in these tables are not isolated, but are linked with some [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dbland.wordpress.com&amp;blog=2215096&amp;post=10&amp;subd=dbland&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As we already discussed, a <a href="http://dbland.wordpress.com/2007/12/09/database-tables/">database table</a> stores the information that is related to a specific entity type. Different entities are stored in different tables, with each table having its own structure, and own attributes related to that entity. In most situations, the entities in these tables are not isolated, but are linked with some kind of relationship. For example, in a corporate environment, we might have a table for employees and a table for departments. However, departments <b>contain</b> employees, or employees <b>work in</b> departments. That is the link between the two entity types.</p>
<p style="text-align:center;"><img src="http://lh3.google.com/amr.elhelw/R2wajlpsqXI/AAAAAAAAAH8/6klaU6FP3k8/s800/2007122101.jpg" /></p>
<p>In databases, this &#8220;<i>link</i>&#8221; is represented by what we call a <b>foreign key</b> relationship. For example, consider the two tables shown. We have a <b>customers</b> table and an <b>Orders</b> table. Each table has its own primary key (which is called <i>ID</i> in both tables). So what is the link between those tables? Well, each order <b>is made by</b> one customer. A customer can make any number of orders. Notice the attribute <i>Cust_ID</i> in the Orders table. This attribute indicates the customer that made each particular order. So for example, order no. 2 is made by customer whose <i>ID</i> is &#8220;024&#8243; (i.e., Bauer). The values in the <i>Cust_ID</i> column refer to the values in the <i>ID</i> column of the Customer table. The <i>Cust_ID</i> column is called a <b>Foreign Key</b>, since it refers to the <i>key</i> (primary key) of another (<i>foreign</i>) table.</p>
<p>So why do we need to do that? Why not just put the customer names in the Order table? The actual reason is called <b>Normalization</b>, which as a whole different topic that we might discuss later on. But for now, think of it as follows: Let&#8217;s say the company found a spelling mistake in Mr. Jack Bauer&#8217;s name (customer no. 024). If the customer name was placed with each single order, then the company would have to go and correct that spelling mistake in every order made my that customer. However, using foreign keys, the company will have to correct the mistake only in the Customers table, and the Orders will still be referring to the correct person.</p>
<p>This leads us to a closely-related concept, which is <b>Referential Integrity</b>. As we mentioned, the Cust_ID column (foreign key) <i>references</i> the ID column (primary key) of the Customer table. The referential integrity rule states that each value in the <i>referring column</i> (Cust_ID) must exist in the <i>referenced column</i> (ID). In other words, we cannot place an order with Cust_ID = 034 without having a customer in the Customers tables with ID = 034.</p>
<p>However, referential integrity might be violated for example, if we try to delete a row from the customer table (when there are orders made my that customer). Databases have multiple ways of ensuring that referential integrity still holds. One common way is to prevent (<i>restrict</i>) deletion in this case. For example, if a user tries to delete customer no. 024 from the Customer table, the database will not perform that action, but will give an error message instead. Another common way is to <i>cascade</i> the deletion process. So, in the above example, when the user tries to delete customer no. 024, the database will perform that action, but it will also delete all orders placed by that customer. So in the end, referential integrity still holds. The choice of which strategy to use can be defined by the user, and depends on the context of the data.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dbland.wordpress.com/10/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dbland.wordpress.com/10/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dbland.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dbland.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dbland.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dbland.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dbland.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dbland.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dbland.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dbland.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dbland.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dbland.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dbland.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dbland.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dbland.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dbland.wordpress.com/10/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dbland.wordpress.com&amp;blog=2215096&amp;post=10&amp;subd=dbland&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dbland.wordpress.com/2007/12/21/foreign-keys-referential-integrity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f4ee5f8a4265aa2318eda20cde661f83?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">aelhelw</media:title>
		</media:content>

		<media:content url="http://lh3.google.com/amr.elhelw/R2wajlpsqXI/AAAAAAAAAH8/6klaU6FP3k8/s800/2007122101.jpg" medium="image" />
	</item>
		<item>
		<title>The Basics (II) &#8211; Database Tables</title>
		<link>http://dbland.wordpress.com/2007/12/09/database-tables/</link>
		<comments>http://dbland.wordpress.com/2007/12/09/database-tables/#comments</comments>
		<pubDate>Sun, 09 Dec 2007 05:05:55 +0000</pubDate>
		<dc:creator>Amr El-Helw</dc:creator>
				<category><![CDATA[Basics]]></category>
		<category><![CDATA[attributes]]></category>
		<category><![CDATA[candidate key]]></category>
		<category><![CDATA[columns]]></category>
		<category><![CDATA[compound key]]></category>
		<category><![CDATA[data types]]></category>
		<category><![CDATA[primary key]]></category>
		<category><![CDATA[relations]]></category>
		<category><![CDATA[rows]]></category>
		<category><![CDATA[tables]]></category>
		<category><![CDATA[tuples]]></category>

		<guid isPermaLink="false">http://dbland.wordpress.com/2007/12/09/database-tables/</guid>
		<description><![CDATA[As mentioned in the previous post, the data in a database are organized into tables. A table (also referred to as a relation) is a set of data elements (values) that is organized using a model of horizontal rows and vertical columns. The data in a table is usually all related to some entity type. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dbland.wordpress.com&amp;blog=2215096&amp;post=9&amp;subd=dbland&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As mentioned in <a href="http://dbland.wordpress.com/2007/11/28/what-is-a-database/">the previous post</a>, the data in a database are organized into <b>tables</b>. A table (also referred to as a <b>relation</b>) is a set of data elements (values) that is organized using a model of horizontal <b>rows</b> and vertical <b>columns</b>. The data in a table is usually all related to some entity type. Each <b>column</b> in the table represents an <b>attribute</b> of that entity, while each <b>row</b> (<b>tuple</b>) represents an instance of that entity. A table has a specified number of columns but can have any number of rows.</p>
<p>Columns (attributes) can be of different types. Possible types include text, numeric, date &amp; time, binary objects, etc. For example, in Figure 1, the &#8220;<i>Last name</i>&#8221; column usually contains textual data while the &#8220;<i>salary</i>&#8221; column contains numeric data.</p>
<p style="text-align:center;"><img src="http://lh4.google.com/amr.elhelw/R03Lmb9JSCI/AAAAAAAAAHc/VhlbWHo94tA/s800/2007112801.jpg" alt="Figure 1 - Employee Table" border="0" height="148" width="519" /><br />
<b>Figure 1 &#8211; Employee Table</b></p>
<p>Each table usually has one of its columns defined as the <b>primary key</b> (or simply the <b>key</b>) of the table. The primary key can be defined as follows: Given a particular value of that column, one can always identify a single row in that table. For example, assume that the table in figure 1 contains an additional column &#8220;ID&#8221;, and assume that each employee has a unique ID. Now if the user looks for any ID value, the system can find the single row corresponding to that ID (since no 2 employees can have the same ID). Any column that satisfies this condition is called a <b>candidate key</b>. One of these candidate keys is selected to be the <b>primary key</b> of the table. On he other hand, the column &#8220;<i>Salary</i>&#8221; is not a candidate key; given a salary value, one cannot identify a single employee with that salary. As a result, the primary key column cannot contain duplicate values. In some cases, however, the primary key is set as a group of columns, instead of a single column. Each of these columns might contain duplicates. However, each combination of values across the whole group of columns is unique. In this case, this primary key is called a <b>compound key</b> or a <b>composite key</b>.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dbland.wordpress.com/9/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dbland.wordpress.com/9/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dbland.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dbland.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dbland.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dbland.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dbland.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dbland.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dbland.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dbland.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dbland.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dbland.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dbland.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dbland.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dbland.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dbland.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dbland.wordpress.com&amp;blog=2215096&amp;post=9&amp;subd=dbland&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dbland.wordpress.com/2007/12/09/database-tables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f4ee5f8a4265aa2318eda20cde661f83?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">aelhelw</media:title>
		</media:content>

		<media:content url="http://lh4.google.com/amr.elhelw/R03Lmb9JSCI/AAAAAAAAAHc/VhlbWHo94tA/s800/2007112801.jpg" medium="image">
			<media:title type="html">Figure 1 - Employee Table</media:title>
		</media:content>
	</item>
		<item>
		<title>The Basics (I) &#8211; What is a Database?</title>
		<link>http://dbland.wordpress.com/2007/11/28/what-is-a-database/</link>
		<comments>http://dbland.wordpress.com/2007/11/28/what-is-a-database/#comments</comments>
		<pubDate>Wed, 28 Nov 2007 20:23:01 +0000</pubDate>
		<dc:creator>Amr El-Helw</dc:creator>
				<category><![CDATA[Basics]]></category>
		<category><![CDATA[general]]></category>
		<category><![CDATA[introduction]]></category>

		<guid isPermaLink="false">http://dbland.wordpress.com/2007/11/28/what-is-a-database/</guid>
		<description><![CDATA[Databases have become involved in virtually every aspect of our lives. Almost everyday, we encounter some kind of a database; while checking out items at the grocery store, making a hotel reservation, searching for a book at the library, etc. So what is a database? It is a collection of related data. Databases have been [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dbland.wordpress.com&amp;blog=2215096&amp;post=4&amp;subd=dbland&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Databases have become involved in virtually every aspect of our lives. Almost everyday, we encounter some kind of a database; while checking out items at the grocery store, making a hotel reservation, searching for a book at the library, etc.</p>
<p><i>So what is a database?</i> It is a collection of related data. Databases have been around for so long, and in different forms. A paper record of information is a database. A text file with information in it can be considered as a database. However, the word Database has become more likely to refer to <b>Relational Databases</b>; a form of databases where data is arranged into tables, each of which consists of rows and columns. From now on, the term database will be used to mean a relational database, unless otherwise specified.</p>
<p>In a relational database, data is stored in <b>tables</b> (also known as <b>relations</b>). Each table usually represents an <b>entity</b> (an item, component, person, project, etc.). Each table has multiples <b>columns</b> (also called <b>fields</b> or <b>attributes</b>). These columns represent different properties of the entity represented by the table. For example, an employee table might have columns like <i>name, hire date, salary, position, department</i>, etc. Each row in that table represents one employee. <b>Rows</b> are also known as <b>records</b> or <b>tuples</b> (see Figure 1)</p>
<p style="text-align:center;"><img src="http://lh4.google.com/amr.elhelw/R03Lmb9JSCI/AAAAAAAAAHc/VhlbWHo94tA/s800/2007112801.jpg" alt="Figure 1 - Employee Table" border="0" height="148" width="519" /><br />
<b>Figure 1 &#8211; Employee Table</b></p>
<p>Now, one cannot put all data in the same table. Why? Well, because things are different. They have different entity types. A student is not the same as an employee. It is true that they are both persons, but each of them has different properties that are of interest. An employee has a salary and a position, while a student has a major and a GPA score. So bottom line: different entities are stores in different tables, with each table containing the relevant columns (attributes) for that particular entity.</p>
<p>So why use databases? Why not just store everything in files? Actually, even databases store data in files on disk. However, to deal with that data, the user does not have to know the <b>physical structure</b> of these files (e.g. how the records are ordered in the file, the size of each record, etc.) All the user has to know is the <b>logical representation</b> of the data (i.e. the table names, what columns they have, etc.) This makes it possible to change the underlying file structure completely without having to get familiar with the new structure.</p>
<p>In order to hide the underlying details, the tables and their structure are encapsulated within a <b>Database Management System (DBMS)</b>. A DBMS is the external shell that the user deals with when creating new tables, managing tables, dealing with the data in the tables, etc. There are many popular commercial DBMSs out there, such as <a href="http://office.microsoft.com/access" target="_blank">Microsoft Access</a>, <a href="http://www.microsoft.com/sql/default.mspx" target="_blank">SQL Server</a>, <a href="http://www.ibm.com/db2" target="_blank">DB2</a>, <a href="http://www.oracle.com/" target="_blank">Oracle</a>, <a href="http://www.postgresql.org/" target="_blank">PostgreSQL</a>, <a href="http://www.mysql.com/" target="_blank">mySQL</a>, etc.</p>
<p>DBMSs provide more flexibility when developing applications that deal with the data, since the applications can be made to interact only with the DBMS, without worrying about the underlying physical details of the file system on which the data is actually stored.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dbland.wordpress.com/4/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dbland.wordpress.com/4/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dbland.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dbland.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dbland.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dbland.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dbland.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dbland.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dbland.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dbland.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dbland.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dbland.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dbland.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dbland.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dbland.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dbland.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dbland.wordpress.com&amp;blog=2215096&amp;post=4&amp;subd=dbland&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dbland.wordpress.com/2007/11/28/what-is-a-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f4ee5f8a4265aa2318eda20cde661f83?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">aelhelw</media:title>
		</media:content>

		<media:content url="http://lh4.google.com/amr.elhelw/R03Lmb9JSCI/AAAAAAAAAHc/VhlbWHo94tA/s800/2007112801.jpg" medium="image">
			<media:title type="html">Figure 1 - Employee Table</media:title>
		</media:content>
	</item>
		<item>
		<title>Welcome to Database Land!!</title>
		<link>http://dbland.wordpress.com/2007/11/27/welcome-to-database-land/</link>
		<comments>http://dbland.wordpress.com/2007/11/27/welcome-to-database-land/#comments</comments>
		<pubDate>Tue, 27 Nov 2007 19:41:03 +0000</pubDate>
		<dc:creator>Amr El-Helw</dc:creator>
				<category><![CDATA[Announcements]]></category>

		<guid isPermaLink="false">http://dbland.wordpress.com/2007/11/27/welcome-to-database-land/</guid>
		<description><![CDATA[Hello everyone&#8230; Since databases are my primary research area, I thought I might as well start blogging about them. I am not quite sure yet what I will be blogging about exactly, but it will be related to databases in one way or the other, so stay tuned. I would like to thank my friend [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dbland.wordpress.com&amp;blog=2215096&amp;post=3&amp;subd=dbland&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hello everyone&#8230;</p>
<p>Since databases are my primary research area, I thought I might as well start blogging about them. I am not quite sure yet what I will be blogging about exactly, but it will be related to databases in one way or the other, so stay tuned.</p>
<p>I would like to thank my friend <em>Brad Moyle</em>, since he inspired me with the name of this blog. It was a casual conversation, when he asked <em>&#8220;..and how are things going in Database land?&#8221;</em>, so Brad, this is dedicated to you!</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dbland.wordpress.com/3/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dbland.wordpress.com/3/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dbland.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dbland.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dbland.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dbland.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dbland.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dbland.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dbland.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dbland.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dbland.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dbland.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dbland.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dbland.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dbland.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dbland.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dbland.wordpress.com&amp;blog=2215096&amp;post=3&amp;subd=dbland&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dbland.wordpress.com/2007/11/27/welcome-to-database-land/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f4ee5f8a4265aa2318eda20cde661f83?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=PG" medium="image">
			<media:title type="html">aelhelw</media:title>
		</media:content>
	</item>
	</channel>
</rss>
