<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
	>
<channel>
	<title>Comments on: Foreign key constraints, DB for real</title>
	<atom:link href="http://wolfram.kriesing.de/blog/index.php/2006/foreign-key-constraints/feed" rel="self" type="application/rss+xml" />
	<link>http://wolfram.kriesing.de/blog/index.php/2006/foreign-key-constraints</link>
	<description>all the other blogs have such cool names, I don't know one ...</description>
	<pubDate>Thu, 09 Feb 2012 16:20:34 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Official Green Bay Packers Jerseys</title>
		<link>http://wolfram.kriesing.de/blog/index.php/2006/foreign-key-constraints/comment-page-1#comment-450225</link>
		<dc:creator>Official Green Bay Packers Jerseys</dc:creator>
		<pubDate>Fri, 13 Jan 2012 07:14:00 +0000</pubDate>
		<guid isPermaLink="false">http://wolfram.kriesing.de/blog/index.php/2006/foreign-key-constraints#comment-450225</guid>
		<description>hello there and thank you to your information – I have definitely picked up anything new from right here. I did alternatively experience several technical issues using this web site, as I skilled to reload the website lots of occasions previous to I could get it to load correctly. I were considering if your hosting is OK? No longer that I'm complaining, but sluggish loading instances times will sometimes impact your placement in google and could injury your high quality ranking if advertising and ***********&#124;advertising&#124;advertising&#124;advertising and *********** with Adwords. Well I’m adding this RSS to my email and could glance out for much extra of your respective interesting content. Ensure that you replace this again soon..</description>
		<content:encoded><![CDATA[<p>hello there and thank you to your information – I have definitely picked up anything new from right here. I did alternatively experience several technical issues using this web site, as I skilled to reload the website lots of occasions previous to I could get it to load correctly. I were considering if your hosting is OK? No longer that I&#8217;m complaining, but sluggish loading instances times will sometimes impact your placement in google and could injury your high quality ranking if advertising and ***********|advertising|advertising|advertising and *********** with Adwords. Well I’m adding this RSS to my email and could glance out for much extra of your respective interesting content. Ensure that you replace this again soon..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jay Pipes</title>
		<link>http://wolfram.kriesing.de/blog/index.php/2006/foreign-key-constraints/comment-page-1#comment-224</link>
		<dc:creator>Jay Pipes</dc:creator>
		<pubDate>Mon, 01 May 2006 14:36:19 +0000</pubDate>
		<guid isPermaLink="false">http://wolfram.kriesing.de/blog/index.php/2006/foreign-key-constraints#comment-224</guid>
		<description>Hi Wolfram!

Just to back up what Lukas was saying, performance of the storage engines depend very much on the application and its needs.  InnoDB performance may be better for reads than MyISAM in some circumstances (high concurrency, for instance) and MyISAM can be better for writes in some circumstances (logging applications, for instance).  The best advice is to build a benchmarking platform and test, test, test :)  Never take anything you hear for granted!

Cheers!</description>
		<content:encoded><![CDATA[<p>Hi Wolfram!</p>
<p>Just to back up what Lukas was saying, performance of the storage engines depend very much on the application and its needs.  InnoDB performance may be better for reads than MyISAM in some circumstances (high concurrency, for instance) and MyISAM can be better for writes in some circumstances (logging applications, for instance).  The best advice is to build a benchmarking platform and test, test, test <img src='http://wolfram.kriesing.de/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Never take anything you hear for granted!</p>
<p>Cheers!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lukas</title>
		<link>http://wolfram.kriesing.de/blog/index.php/2006/foreign-key-constraints/comment-page-1#comment-219</link>
		<dc:creator>Lukas</dc:creator>
		<pubDate>Mon, 17 Apr 2006 16:36:47 +0000</pubDate>
		<guid isPermaLink="false">http://wolfram.kriesing.de/blog/index.php/2006/foreign-key-constraints#comment-219</guid>
		<description>@Maarten: that depends on what you are doing .. for high concurrency between reads and writes InnoDB is faster due to row level locking and MVCC.

For reads only MyISAM is faster. It also does some aggregates faster because it does not have MVCC.

You have to look at what features you need and how you are interacting with your database to choose the proper table engine.</description>
		<content:encoded><![CDATA[<p>@Maarten: that depends on what you are doing .. for high concurrency between reads and writes InnoDB is faster due to row level locking and MVCC.</p>
<p>For reads only MyISAM is faster. It also does some aggregates faster because it does not have MVCC.</p>
<p>You have to look at what features you need and how you are interacting with your database to choose the proper table engine.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ivo Jansch</title>
		<link>http://wolfram.kriesing.de/blog/index.php/2006/foreign-key-constraints/comment-page-1#comment-218</link>
		<dc:creator>Ivo Jansch</dc:creator>
		<pubDate>Mon, 17 Apr 2006 16:27:00 +0000</pubDate>
		<guid isPermaLink="false">http://wolfram.kriesing.de/blog/index.php/2006/foreign-key-constraints#comment-218</guid>
		<description>Hmm, you're right, leaving out the type only seems to work in Oracle. I confused things :)</description>
		<content:encoded><![CDATA[<p>Hmm, you&#8217;re right, leaving out the type only seems to work in Oracle. I confused things <img src='http://wolfram.kriesing.de/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Maarten Manders</title>
		<link>http://wolfram.kriesing.de/blog/index.php/2006/foreign-key-constraints/comment-page-1#comment-217</link>
		<dc:creator>Maarten Manders</dc:creator>
		<pubDate>Mon, 17 Apr 2006 16:17:01 +0000</pubDate>
		<guid isPermaLink="false">http://wolfram.kriesing.de/blog/index.php/2006/foreign-key-constraints#comment-217</guid>
		<description>Isn't InnnoDB a whole lot slower than MyISAM?</description>
		<content:encoded><![CDATA[<p>Isn&#8217;t InnnoDB a whole lot slower than MyISAM?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wolfram</title>
		<link>http://wolfram.kriesing.de/blog/index.php/2006/foreign-key-constraints/comment-page-1#comment-216</link>
		<dc:creator>Wolfram</dc:creator>
		<pubDate>Mon, 17 Apr 2006 16:09:31 +0000</pubDate>
		<guid isPermaLink="false">http://wolfram.kriesing.de/blog/index.php/2006/foreign-key-constraints#comment-216</guid>
		<description>Ivo, but your statement doesn't work! It always raises:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NOT NULL,
title varchar(20) NOT NULL,
PRIMARY KEY pk_subchapter (subchapter_id' at line 3 

seems you can't leave out the type ... even though it would make sense ... what's wrong?</description>
		<content:encoded><![CDATA[<p>Ivo, but your statement doesn&#8217;t work! It always raises:</p>
<p>#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near &#8216;NOT NULL,<br />
title varchar(20) NOT NULL,<br />
PRIMARY KEY pk_subchapter (subchapter_id&#8217; at line 3 </p>
<p>seems you can&#8217;t leave out the type &#8230; even though it would make sense &#8230; what&#8217;s wrong?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wolfram</title>
		<link>http://wolfram.kriesing.de/blog/index.php/2006/foreign-key-constraints/comment-page-1#comment-215</link>
		<dc:creator>Wolfram</dc:creator>
		<pubDate>Mon, 17 Apr 2006 15:50:52 +0000</pubDate>
		<guid isPermaLink="false">http://wolfram.kriesing.de/blog/index.php/2006/foreign-key-constraints#comment-215</guid>
		<description>ah yes, no type at all is even cooler and even more logical :-) thx</description>
		<content:encoded><![CDATA[<p>ah yes, no type at all is even cooler and even more logical <img src='http://wolfram.kriesing.de/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> thx</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ivo Jansch</title>
		<link>http://wolfram.kriesing.de/blog/index.php/2006/foreign-key-constraints/comment-page-1#comment-214</link>
		<dc:creator>Ivo Jansch</dc:creator>
		<pubDate>Mon, 17 Apr 2006 15:43:01 +0000</pubDate>
		<guid isPermaLink="false">http://wolfram.kriesing.de/blog/index.php/2006/foreign-key-constraints#comment-214</guid>
		<description>Some hints: don't specify the type of a foreign key at all. It will automatically pick the type of the field it references. Also, I find it cleaner to give the constraints a name so they don't get an autogenerated key name. 

The ON UPDATE CASCADE is not really necessarry for numerical keys as you're not going to change these ever.

Finally, I think it's not necessary to have both a key and a foreign key on the same field. As a foreign key is a regular key as well.

Your example for subchapter would then become:

CREATE TABLE subchapter (
subchapter_id int(11) unsigned NOT NULL auto_increment,
chapter_id NOT NULL,
title varchar(20) NOT NULL,
PRIMARY KEY pk_subchapter (subchapter_id),,
FOREIGN KEY fk_subchapter_ch (chapter_id) REFERENCES chapter(chapter_id)
ON DELETE CASCADE
) ENGINE=InnoDB;

Note how chapter_id does not have a type here.</description>
		<content:encoded><![CDATA[<p>Some hints: don&#8217;t specify the type of a foreign key at all. It will automatically pick the type of the field it references. Also, I find it cleaner to give the constraints a name so they don&#8217;t get an autogenerated key name. </p>
<p>The ON UPDATE CASCADE is not really necessarry for numerical keys as you&#8217;re not going to change these ever.</p>
<p>Finally, I think it&#8217;s not necessary to have both a key and a foreign key on the same field. As a foreign key is a regular key as well.</p>
<p>Your example for subchapter would then become:</p>
<p>CREATE TABLE subchapter (<br />
subchapter_id int(11) unsigned NOT NULL auto_increment,<br />
chapter_id NOT NULL,<br />
title varchar(20) NOT NULL,<br />
PRIMARY KEY pk_subchapter (subchapter_id),,<br />
FOREIGN KEY fk_subchapter_ch (chapter_id) REFERENCES chapter(chapter_id)<br />
ON DELETE CASCADE<br />
) ENGINE=InnoDB;</p>
<p>Note how chapter_id does not have a type here.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

