<?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: Versioning MySQL data: Multi-table records</title>
	<atom:link href="http://www.jasny.net/articles/versioning-mysql-data-multi-table-records/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jasny.net/articles/versioning-mysql-data-multi-table-records/</link>
	<description>It&#039;s all about me, mysql and Einstein.</description>
	<lastBuildDate>Thu, 09 Sep 2010 15:08:00 +0100</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Arnold Daniels</title>
		<link>http://www.jasny.net/articles/versioning-mysql-data-multi-table-records/comment-page-1/#comment-229865</link>
		<dc:creator>Arnold Daniels</dc:creator>
		<pubDate>Mon, 10 May 2010 11:05:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.adaniels.nl/?p=342#comment-229865</guid>
		<description>&lt;b&gt;&lt;em&gt;May: &lt;/em&gt;&lt;/b&gt; The script currently doesn&#039;t do this. You can add this though.

The mytable-afterupdate trigger needs to insert a revision record for all descendants (not only direct children).
&lt;pre lang=&quot;SQL&quot;&gt;
INSERT INTO `_revision_mysubchild` SELECT `s`.*, NEW.`_revision` FROM `mysubchild` AS `t` INNER JOIN `mychild` AS `c` ON `t`.`mychild_id` = `c`.`id` WHERE `c`.`mytable_id` = NEW.`id`;
&lt;/pre&gt;

For changing the revision the SQL would look like
&lt;pre lang=&quot;SQL&quot;&gt;
DELETE `t`.* FROM `mysubchild` AS `t` INNER JOIN `mychild` AS `c` ON `t`.`mychild_id` = `c`.`id` LEFT JOIN `_revision_mysubchild` AS `r` ON 0=1 WHERE `c`.`mytable_id` = NEW.`id`;
INSERT INTO `mysubchild` SELECT `id`, `mychild_id`, `somefield` FROM `_revision_mysubchild` WHERE `_revision` = NEW.`_revision`;
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p><b><em>May: </em></b> The script currently doesn&#8217;t do this. You can add this though.</p>
<p>The mytable-afterupdate trigger needs to insert a revision record for all descendants (not only direct children).</p>

<div class="wp_syntax"><div class="code"><pre class="sql"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`_revision_mysubchild`</span> <span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #ff0000;">`s`</span>.*, NEW.<span style="color: #ff0000;">`_revision`</span> <span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #ff0000;">`mysubchild`</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #ff0000;">`t`</span> <span style="color: #993333; font-weight: bold;">INNER</span> <span style="color: #993333; font-weight: bold;">JOIN</span> <span style="color: #ff0000;">`mychild`</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #ff0000;">`c`</span> <span style="color: #993333; font-weight: bold;">ON</span> <span style="color: #ff0000;">`t`</span>.<span style="color: #ff0000;">`mychild_id`</span> = <span style="color: #ff0000;">`c`</span>.<span style="color: #ff0000;">`id`</span> <span style="color: #993333; font-weight: bold;">WHERE</span> <span style="color: #ff0000;">`c`</span>.<span style="color: #ff0000;">`mytable_id`</span> = NEW.<span style="color: #ff0000;">`id`</span>;</pre></div></div>

<p>For changing the revision the SQL would look like</p>

<div class="wp_syntax"><div class="code"><pre class="sql"><span style="color: #993333; font-weight: bold;">DELETE</span> <span style="color: #ff0000;">`t`</span>.* <span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #ff0000;">`mysubchild`</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #ff0000;">`t`</span> <span style="color: #993333; font-weight: bold;">INNER</span> <span style="color: #993333; font-weight: bold;">JOIN</span> <span style="color: #ff0000;">`mychild`</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #ff0000;">`c`</span> <span style="color: #993333; font-weight: bold;">ON</span> <span style="color: #ff0000;">`t`</span>.<span style="color: #ff0000;">`mychild_id`</span> = <span style="color: #ff0000;">`c`</span>.<span style="color: #ff0000;">`id`</span> <span style="color: #993333; font-weight: bold;">LEFT</span> <span style="color: #993333; font-weight: bold;">JOIN</span> <span style="color: #ff0000;">`_revision_mysubchild`</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #ff0000;">`r`</span> <span style="color: #993333; font-weight: bold;">ON</span> <span style="color: #cc66cc;">0</span>=<span style="color: #cc66cc;">1</span> <span style="color: #993333; font-weight: bold;">WHERE</span> <span style="color: #ff0000;">`c`</span>.<span style="color: #ff0000;">`mytable_id`</span> = NEW.<span style="color: #ff0000;">`id`</span>;
<span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`mysubchild`</span> <span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #ff0000;">`id`</span>, <span style="color: #ff0000;">`mychild_id`</span>, <span style="color: #ff0000;">`somefield`</span> <span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #ff0000;">`_revision_mysubchild`</span> <span style="color: #993333; font-weight: bold;">WHERE</span> <span style="color: #ff0000;">`_revision`</span> = NEW.<span style="color: #ff0000;">`_revision`</span>;</pre></div></div>

]]></content:encoded>
	</item>
	<item>
		<title>By: May</title>
		<link>http://www.jasny.net/articles/versioning-mysql-data-multi-table-records/comment-page-1/#comment-228401</link>
		<dc:creator>May</dc:creator>
		<pubDate>Thu, 06 May 2010 20:52:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.adaniels.nl/?p=342#comment-228401</guid>
		<description>Hi,
How do I create parent/child revisioning in case that child has another child table? Let&#039;s say I have tables like this

Parent (id, column...)
   Child (id, parent_id)
      SubChild (id, child_id)

I want to do versioning only for parent table, but if I switch revision I want also child table as well as sub-child table to be switched. Is it possible to do using your script?

Thanks</description>
		<content:encoded><![CDATA[<p>Hi,<br />
How do I create parent/child revisioning in case that child has another child table? Let&#8217;s say I have tables like this</p>
<p>Parent (id, column&#8230;)<br />
   Child (id, parent_id)<br />
      SubChild (id, child_id)</p>
<p>I want to do versioning only for parent table, but if I switch revision I want also child table as well as sub-child table to be switched. Is it possible to do using your script?</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arnold Daniels</title>
		<link>http://www.jasny.net/articles/versioning-mysql-data-multi-table-records/comment-page-1/#comment-212159</link>
		<dc:creator>Arnold Daniels</dc:creator>
		<pubDate>Mon, 21 Dec 2009 12:10:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.adaniels.nl/?p=342#comment-212159</guid>
		<description>&lt;strong&gt;&lt;em&gt;Edmund, Peter: &lt;/em&gt;&lt;/strong&gt;The downloadable script, does multi-table revisioning.  (Only single table isn&#039;t available)

The parent-child relationship is based on a &lt;a href=&quot;http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html&quot; rel=&quot;nofollow&quot;&gt;foreign key constraint&lt;/a&gt;. MyISAM doesn&#039;t support foreign keys, so you can&#039;t do parent-child relationships with MyISAM tables.

To create parent/child revisioning do
&lt;pre&gt;
php mysql-revisioning.php &#039;parent(child1,child2)&#039; another_table ...
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p><strong><em>Edmund, Peter: </em></strong>The downloadable script, does multi-table revisioning.  (Only single table isn&#8217;t available)</p>
<p>The parent-child relationship is based on a <a href="http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html" rel="nofollow">foreign key constraint</a>. MyISAM doesn&#8217;t support foreign keys, so you can&#8217;t do parent-child relationships with MyISAM tables.</p>
<p>To create parent/child revisioning do</p>
<pre>
php mysql-revisioning.php 'parent(child1,child2)' another_table ...
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter</title>
		<link>http://www.jasny.net/articles/versioning-mysql-data-multi-table-records/comment-page-1/#comment-212100</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Sun, 20 Dec 2009 17:13:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.adaniels.nl/?p=342#comment-212100</guid>
		<description>The generated trigger with no different from the previous one? 

How the script know the relationship between parent and child table?</description>
		<content:encoded><![CDATA[<p>The generated trigger with no different from the previous one? </p>
<p>How the script know the relationship between parent and child table?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Edmund</title>
		<link>http://www.jasny.net/articles/versioning-mysql-data-multi-table-records/comment-page-1/#comment-212099</link>
		<dc:creator>Edmund</dc:creator>
		<pubDate>Sun, 20 Dec 2009 16:53:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.adaniels.nl/?p=342#comment-212099</guid>
		<description>Could you upload the php script to generating triggers for Multi-table records versioning? I found the link posted is for single table only

Thanks</description>
		<content:encoded><![CDATA[<p>Could you upload the php script to generating triggers for Multi-table records versioning? I found the link posted is for single table only</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Log Buffer</title>
		<link>http://www.jasny.net/articles/versioning-mysql-data-multi-table-records/comment-page-1/#comment-211340</link>
		<dc:creator>Log Buffer</dc:creator>
		<pubDate>Fri, 04 Dec 2009 20:17:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.adaniels.nl/?p=342#comment-211340</guid>
		<description>&quot;[...]Arnold Daniels delves into versioning MySQL data across multi-table records.[...]&quot;

&lt;a href=&quot;http://www.pythian.com/news/6165/log-buffer-171-a-carnival-of-the-vanities-for-dbas/&quot; rel=&quot;nofollow&quot;&gt;Log Buffer #171&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>&#8220;[...]Arnold Daniels delves into versioning MySQL data across multi-table records.[...]&#8221;</p>
<p><a href="http://www.pythian.com/news/6165/log-buffer-171-a-carnival-of-the-vanities-for-dbas/" rel="nofollow">Log Buffer #171</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>
