<?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: InnoDB, Composite Keys, and ON DUPLICATE KEY</title>
	<atom:link href="http://www.jqueryin.com/2009/04/06/innodb-composite-keys-and-on-duplicate-key/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jqueryin.com/2009/04/06/innodb-composite-keys-and-on-duplicate-key/</link>
	<description>A web development blog focusing on PHP, MySQL, Javascript, jQuery, and CSS.</description>
	<lastBuildDate>Thu, 26 Jan 2012 14:32:59 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: cballou</title>
		<link>http://www.jqueryin.com/2009/04/06/innodb-composite-keys-and-on-duplicate-key/comment-page-1/#comment-20</link>
		<dc:creator>cballou</dc:creator>
		<pubDate>Tue, 16 Mar 2010 13:40:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.jqueryin.com/wordpress/?p=3#comment-20</guid>
		<description>The choice to store an auto incrementing key is that I have always considered it good practice to store auto incrementing keys for nearly all tables (with the exception of pivot tables) because it allows for easier migrations in the event my site&#039;s overall table structure need to undergo a drastic change.  To be quite honest, looking back at the code, I can&#039;t actually pinpoint why I had decided to not use a composite key with a leftmost prefix of &lt;strong&gt;photosets.photoset_id&lt;/strong&gt; in favor of &lt;strong&gt;photosets.id&lt;/strong&gt;.   If I had to do it all over again, I probably would have gone with PRIMARY KEY(photoset_id, id).  Hindsight is always great though, right?</description>
		<content:encoded><![CDATA[<p>The choice to store an auto incrementing key is that I have always considered it good practice to store auto incrementing keys for nearly all tables (with the exception of pivot tables) because it allows for easier migrations in the event my site&#8217;s overall table structure need to undergo a drastic change.  To be quite honest, looking back at the code, I can&#8217;t actually pinpoint why I had decided to not use a composite key with a leftmost prefix of <strong>photosets.photoset_id</strong> in favor of <strong>photosets.id</strong>.   If I had to do it all over again, I probably would have gone with PRIMARY KEY(photoset_id, id).  Hindsight is always great though, right?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alok</title>
		<link>http://www.jqueryin.com/2009/04/06/innodb-composite-keys-and-on-duplicate-key/comment-page-1/#comment-19</link>
		<dc:creator>Alok</dc:creator>
		<pubDate>Tue, 16 Mar 2010 13:17:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.jqueryin.com/wordpress/?p=3#comment-19</guid>
		<description>Interesting… Why did you not make id your primary key? The difference is that the primary key is copied to all other indexes in innodb, and a varchar(50) field is bigger than an unsigned int. Minor point: a composite primary key usually implies that neither field alone is unique, but in your case it looks like you have two keys which are unique on their own. For example, if you had PRIMARY KEY (id, photoset_id), it would only count as a duplicate if you inserted a row that matched on both values – having a composite primary key is not the same as having two separate unique indexes, just like UNIQUE(id), UNIQUE(photoset_id) is not the same as UNIQUE(id, photoset_id).</description>
		<content:encoded><![CDATA[<p>Interesting… Why did you not make id your primary key? The difference is that the primary key is copied to all other indexes in innodb, and a varchar(50) field is bigger than an unsigned int. Minor point: a composite primary key usually implies that neither field alone is unique, but in your case it looks like you have two keys which are unique on their own. For example, if you had PRIMARY KEY (id, photoset_id), it would only count as a duplicate if you inserted a row that matched on both values – having a composite primary key is not the same as having two separate unique indexes, just like UNIQUE(id), UNIQUE(photoset_id) is not the same as UNIQUE(id, photoset_id).</p>
]]></content:encoded>
	</item>
</channel>
</rss>

