<?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>Dave Rowe's Blog &#187; mysql</title>
	<atom:link href="http://blog.roweware.com/tag/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.roweware.com</link>
	<description>Ramblings about things I think I know...</description>
	<lastBuildDate>Wed, 14 Jul 2010 17:45:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>MySQL Multi-Table Delete</title>
		<link>http://blog.roweware.com/2009/12/08/mysql-multi-table-delete/</link>
		<comments>http://blog.roweware.com/2009/12/08/mysql-multi-table-delete/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 19:27:20 +0000</pubDate>
		<dc:creator>Dave Rowe</dc:creator>
				<category><![CDATA[Database Design]]></category>
		<category><![CDATA[joins]]></category>
		<category><![CDATA[multi-delete]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://blog.roweware.com/?p=142</guid>
		<description><![CDATA[MySQL provides cascading updates / deletes with the relationships, but I tend not to use them, specifically because I want to control just how far these updates and deletes cascade!  But, given a situation where I have a design similar to this: I would like to be able to remove a single Foo, without having [...]]]></description>
			<content:encoded><![CDATA[<p>MySQL provides cascading updates / deletes with the relationships, but I tend not to use them, specifically because I want to control just how far these updates and deletes cascade!  But, given a situation where I have a design similar to this:</p>
<p style="text-align: center;"><img class="size-full wp-image-143 aligncenter" title="multi-delete" src="http://blog.roweware.com/wp-content/uploads/2009/12/multi-delete.png" alt="multi-delete" width="270" height="255" /></p>
<p>I would like to be able to remove a single Foo, without having to first remove all the associated data from the other 3 tables.  Or, I know the ID of the Foo I want to remove, so instead of running multiple queries to find the associated rows, lets just knock it out with a single, multi-table delete!</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p142code2'); return false;">View Code</a> SQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p1422"><td class="code" id="p142code2"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">DELETE</span>
  db<span style="color: #66cc66;">.</span>zap <span style="color: #993333; font-weight: bold;">as</span> z<span style="color: #66cc66;">,</span>
  db<span style="color: #66cc66;">.</span>baz <span style="color: #993333; font-weight: bold;">as</span> bz<span style="color: #66cc66;">,</span>
  db<span style="color: #66cc66;">.</span>bar <span style="color: #993333; font-weight: bold;">as</span> z<span style="color: #66cc66;">,</span>
  db<span style="color: #66cc66;">.</span>foo <span style="color: #993333; font-weight: bold;">as</span> f
<span style="color: #993333; font-weight: bold;">FROM</span>
  db<span style="color: #66cc66;">.</span>zap <span style="color: #993333; font-weight: bold;">as</span> b<span style="color: #66cc66;">,</span>
  db<span style="color: #66cc66;">.</span>baz <span style="color: #993333; font-weight: bold;">as</span> bz<span style="color: #66cc66;">,</span>
  db<span style="color: #66cc66;">.</span>bar <span style="color: #993333; font-weight: bold;">as</span> z<span style="color: #66cc66;">,</span>
  db<span style="color: #66cc66;">.</span>foo <span style="color: #993333; font-weight: bold;">as</span> f
<span style="color: #993333; font-weight: bold;">WHERE</span>
  b<span style="color: #66cc66;">.</span>baz_id <span style="color: #66cc66;">=</span> bz<span style="color: #66cc66;">.</span>id <span style="color: #993333; font-weight: bold;">AND</span>
  b<span style="color: #66cc66;">.</span>zap_id <span style="color: #66cc66;">=</span> z<span style="color: #66cc66;">.</span>id <span style="color: #993333; font-weight: bold;">AND</span>
  bz<span style="color: #66cc66;">.</span>foo_id <span style="color: #66cc66;">=</span> f<span style="color: #66cc66;">.</span>id <span style="color: #993333; font-weight: bold;">AND</span>
  z<span style="color: #66cc66;">.</span>foo_id <span style="color: #66cc66;">=</span> f<span style="color: #66cc66;">.</span>id <span style="color: #993333; font-weight: bold;">AND</span>
  f<span style="color: #66cc66;">.</span>id <span style="color: #66cc66;">=</span> ?</pre></td></tr></table></div>

<p>This will then remove the rows associated with the single Foo record I&#8217;ve referenced, in one fell swoop.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.roweware.com/2009/12/08/mysql-multi-table-delete/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adventures in Database Design</title>
		<link>http://blog.roweware.com/2009/11/23/adventures-in-database-design/</link>
		<comments>http://blog.roweware.com/2009/11/23/adventures-in-database-design/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 03:39:56 +0000</pubDate>
		<dc:creator>Dave Rowe</dc:creator>
				<category><![CDATA[Database Design]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[workbench]]></category>

		<guid isPermaLink="false">http://blog.roweware.com/?p=137</guid>
		<description><![CDATA[I&#8217;ve long neglected this blog, and the power behind it to discuss my feelings toward database design.  Proper database design is the backbone to a solid application.  Failing to correctly normalize tables and enforce business logic with foreign key relationships can cause undue headaches. What I&#8217;ll be doing is going through some simple applications, and [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve long neglected this blog, and the power behind it to discuss my feelings toward database design.  Proper database design is the backbone to a solid application.  Failing to correctly normalize tables and enforce business logic with foreign key relationships can cause undue headaches.</p>
<p>What I&#8217;ll be doing is going through some simple applications, and start modeling the tables and relationships, and intersperse some commentary where useful.  The discussion depends on interaction, and I&#8217;m of the opinion that a &#8216;good&#8217; database designer can a) defend their design articulately and b) know when to concede a good point.</p>
<p>Database design is becoming organic.  Strict adherence to the normal forms isn&#8217;t required any longer.  Let me be clear though, denormalizing a table to make things easier for a developer is not a valid reason to denormalize.</p>
<p>The modeling tool I&#8217;ll be using for generating the images is <a title="MySQL Workbench" href="http://wb.mysql.com/" target="_blank">MySQL Workbench</a>.  Workbench is a very powerful tool, from the source of one of the most powerful (and used) databases today.  I cut my teeth on database design with DBDesigner4, whose creator went on to work for MySQL Workbench.</p>
<p>Stay tuned.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.roweware.com/2009/11/23/adventures-in-database-design/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
