<?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: Triggers Use Case Compilation, Part I</title>
	<atom:link href="http://code.openark.org/blog/mysql/triggers-use-case-compilation-part-i/feed" rel="self" type="application/rss+xml" />
	<link>http://code.openark.org/blog/mysql/triggers-use-case-compilation-part-i</link>
	<description>Blog by Shlomi Noach</description>
	<lastBuildDate>Fri, 14 Jun 2013 10:55:23 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
	<item>
		<title>By: Impact of foreign keys absence on replicating slaves &#124; code.openark.org</title>
		<link>http://code.openark.org/blog/mysql/triggers-use-case-compilation-part-i/comment-page-1#comment-91016</link>
		<dc:creator>Impact of foreign keys absence on replicating slaves &#124; code.openark.org</dc:creator>
		<pubDate>Mon, 14 May 2012 05:52:49 +0000</pubDate>
		<guid isPermaLink="false">http://code.openark.org/blog/?p=313#comment-91016</guid>
		<description><![CDATA[[...] rely on integrity with cascading constraints. An ugly patch might be to use triggers so as to simulate their behavior. Performance wise this is very bad. [...]]]></description>
		<content:encoded><![CDATA[<p>[...] rely on integrity with cascading constraints. An ugly patch might be to use triggers so as to simulate their behavior. Performance wise this is very bad. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: When are MySQL Triggers not a good idea? &#124; DIGG LINK</title>
		<link>http://code.openark.org/blog/mysql/triggers-use-case-compilation-part-i/comment-page-1#comment-65679</link>
		<dc:creator>When are MySQL Triggers not a good idea? &#124; DIGG LINK</dc:creator>
		<pubDate>Mon, 09 Jan 2012 19:11:54 +0000</pubDate>
		<guid isPermaLink="false">http://code.openark.org/blog/?p=313#comment-65679</guid>
		<description><![CDATA[[...] read the docs, FAQs, Forum and other sites and witnessed plenty of use cases, but haven’t come across a discussion of best [...]]]></description>
		<content:encoded><![CDATA[<p>[...] read the docs, FAQs, Forum and other sites and witnessed plenty of use cases, but haven’t come across a discussion of best [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL: forcing single row tables integrity &#124; code.openark.org</title>
		<link>http://code.openark.org/blog/mysql/triggers-use-case-compilation-part-i/comment-page-1#comment-15027</link>
		<dc:creator>SQL: forcing single row tables integrity &#124; code.openark.org</dc:creator>
		<pubDate>Tue, 22 Jun 2010 04:58:57 +0000</pubDate>
		<guid isPermaLink="false">http://code.openark.org/blog/?p=313#comment-15027</guid>
		<description><![CDATA[[...] Triggers Use Case Compilation, Part I [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Triggers Use Case Compilation, Part I [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Samuel</title>
		<link>http://code.openark.org/blog/mysql/triggers-use-case-compilation-part-i/comment-page-1#comment-12339</link>
		<dc:creator>Samuel</dc:creator>
		<pubDate>Sun, 18 Apr 2010 22:52:10 +0000</pubDate>
		<guid isPermaLink="false">http://code.openark.org/blog/?p=313#comment-12339</guid>
		<description><![CDATA[@Shlomi,

Kindly appreciate the notice.

The triggers are for insert and update on the reference tables -- the master dictionary if you will.  Trigger firings, therefore, are extremely rare -- the frequency of &quot;discovering&quot; a new word to add.  These reference tables are virtually read only.

The more active write tables are strictly no-frills word-usage data collection.  No triggers involved.]]></description>
		<content:encoded><![CDATA[<p>@Shlomi,</p>
<p>Kindly appreciate the notice.</p>
<p>The triggers are for insert and update on the reference tables -- the master dictionary if you will.  Trigger firings, therefore, are extremely rare -- the frequency of "discovering" a new word to add.  These reference tables are virtually read only.</p>
<p>The more active write tables are strictly no-frills word-usage data collection.  No triggers involved.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shlomi</title>
		<link>http://code.openark.org/blog/mysql/triggers-use-case-compilation-part-i/comment-page-1#comment-12331</link>
		<dc:creator>shlomi</dc:creator>
		<pubDate>Sun, 18 Apr 2010 06:45:14 +0000</pubDate>
		<guid isPermaLink="false">http://code.openark.org/blog/?p=313#comment-12331</guid>
		<description><![CDATA[@Samuel,

With pleasure. Do take notice that triggers will *considerably* slow down your queries. If this is a one time job, for importing data from MSSQL, this may be fine; but make sure to check on your performance if you&#039;re going live with active triggers.]]></description>
		<content:encoded><![CDATA[<p>@Samuel,</p>
<p>With pleasure. Do take notice that triggers will *considerably* slow down your queries. If this is a one time job, for importing data from MSSQL, this may be fine; but make sure to check on your performance if you're going live with active triggers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Samuel</title>
		<link>http://code.openark.org/blog/mysql/triggers-use-case-compilation-part-i/comment-page-1#comment-12329</link>
		<dc:creator>Samuel</dc:creator>
		<pubDate>Sun, 18 Apr 2010 06:34:03 +0000</pubDate>
		<guid isPermaLink="false">http://code.openark.org/blog/?p=313#comment-12329</guid>
		<description><![CDATA[Thank you for your generous contribution.

I am in the process of moving a large very specialized linguistic database in MS SQL to MySQL  (way cheaper on aws.amazon).  Referential integrity was enforced in SQL Server using triggrs that checked the inserted values against views -- this was the ONLY way possible given the highly customized way words in this database are categorized (over 400 unique lexical senses).  I was beating my head bloody trying to figure out a way to &quot;trick&quot; MySQL into similar functionality, and happily like the song says &quot;then came you!&quot;

Again, thank you for your generosity sharing your knowledge.]]></description>
		<content:encoded><![CDATA[<p>Thank you for your generous contribution.</p>
<p>I am in the process of moving a large very specialized linguistic database in MS SQL to MySQL  (way cheaper on aws.amazon).  Referential integrity was enforced in SQL Server using triggrs that checked the inserted values against views -- this was the ONLY way possible given the highly customized way words in this database are categorized (over 400 unique lexical senses).  I was beating my head bloody trying to figure out a way to "trick" MySQL into similar functionality, and happily like the song says "then came you!"</p>
<p>Again, thank you for your generosity sharing your knowledge.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Triggers Use Case Compilation, Part III &#124; code.openark.org</title>
		<link>http://code.openark.org/blog/mysql/triggers-use-case-compilation-part-i/comment-page-1#comment-503</link>
		<dc:creator>Triggers Use Case Compilation, Part III &#124; code.openark.org</dc:creator>
		<pubDate>Mon, 02 Feb 2009 11:23:42 +0000</pubDate>
		<guid isPermaLink="false">http://code.openark.org/blog/?p=313#comment-503</guid>
		<description><![CDATA[[...] Triggers Use Case Compilation, Part III [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Triggers Use Case Compilation, Part III [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shlomi</title>
		<link>http://code.openark.org/blog/mysql/triggers-use-case-compilation-part-i/comment-page-1#comment-320</link>
		<dc:creator>shlomi</dc:creator>
		<pubDate>Fri, 16 Jan 2009 05:26:49 +0000</pubDate>
		<guid isPermaLink="false">http://code.openark.org/blog/?p=313#comment-320</guid>
		<description><![CDATA[Roland,

thanks for this important correction. I&#039;ve updated the text. I have to check how I came to that conclusion.

In your sample code above, it is best if you specified ENGINE=InnoDB for those who have MyISAM as default storage engine.

When doing the above with MyISAM, no error is ever produced. Moreover, trying to ALTER tables to InnoDB still works fine, since the foreign key was silently dropped as we were using MyISAM. Will check if there&#039;s an open bug on this.

Regards,
Shlomi]]></description>
		<content:encoded><![CDATA[<p>Roland,</p>
<p>thanks for this important correction. I've updated the text. I have to check how I came to that conclusion.</p>
<p>In your sample code above, it is best if you specified ENGINE=InnoDB for those who have MyISAM as default storage engine.</p>
<p>When doing the above with MyISAM, no error is ever produced. Moreover, trying to ALTER tables to InnoDB still works fine, since the foreign key was silently dropped as we were using MyISAM. Will check if there's an open bug on this.</p>
<p>Regards,<br />
Shlomi</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roland Bouman</title>
		<link>http://code.openark.org/blog/mysql/triggers-use-case-compilation-part-i/comment-page-1#comment-313</link>
		<dc:creator>Roland Bouman</dc:creator>
		<pubDate>Thu, 15 Jan 2009 23:11:14 +0000</pubDate>
		<guid isPermaLink="false">http://code.openark.org/blog/?p=313#comment-313</guid>
		<description><![CDATA[Hi! sorry - there should be a: 

USE t2 

after the 

create database t2;

But, it works across schemata nonetheless....]]></description>
		<content:encoded><![CDATA[<p>Hi! sorry - there should be a: </p>
<p>USE t2 </p>
<p>after the </p>
<p>create database t2;</p>
<p>But, it works across schemata nonetheless....</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roland Bouman</title>
		<link>http://code.openark.org/blog/mysql/triggers-use-case-compilation-part-i/comment-page-1#comment-312</link>
		<dc:creator>Roland Bouman</dc:creator>
		<pubDate>Thu, 15 Jan 2009 23:08:38 +0000</pubDate>
		<guid isPermaLink="false">http://code.openark.org/blog/?p=313#comment-312</guid>
		<description><![CDATA[Hi!

&quot;An interesting point, though, is exposed here: trigger-based integrity can work cross-schemata, whereas InnoDB’s foreign keys only work withing a given schema.&quot;

I don&#039;t think this is true.

mysql&gt; use t1
Database changed
mysql&gt; create table t1 (id int primary key);
Query OK, 0 rows affected (0.23 sec)

mysql&gt; create database t2;
Query OK, 1 row affected (0.00 sec)

mysql&gt; create table t2 (id int, foreign key(id) references t1.t1 (id));
Query OK, 0 rows affected (0.11 sec)

mysql&gt; insert into t2 values (1);
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`t1`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`id`) REFERENCES `t1` (`id`))

mysql&gt; insert into t1.t1 values (1);
Query OK, 1 row affected (0.13 sec)

mysql&gt; insert into t2 values (1);
Query OK, 1 row affected (0.09 sec)

mysql&gt; delete from t1.t1;
ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (`t1`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`id`) REFERENCES `t1` (`id`))


So, it works for me.]]></description>
		<content:encoded><![CDATA[<p>Hi!</p>
<p>"An interesting point, though, is exposed here: trigger-based integrity can work cross-schemata, whereas InnoDB’s foreign keys only work withing a given schema."</p>
<p>I don't think this is true.</p>
<p>mysql&gt; use t1<br />
Database changed<br />
mysql&gt; create table t1 (id int primary key);<br />
Query OK, 0 rows affected (0.23 sec)</p>
<p>mysql&gt; create database t2;<br />
Query OK, 1 row affected (0.00 sec)</p>
<p>mysql&gt; create table t2 (id int, foreign key(id) references t1.t1 (id));<br />
Query OK, 0 rows affected (0.11 sec)</p>
<p>mysql&gt; insert into t2 values (1);<br />
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`t1`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`id`) REFERENCES `t1` (`id`))</p>
<p>mysql&gt; insert into t1.t1 values (1);<br />
Query OK, 1 row affected (0.13 sec)</p>
<p>mysql&gt; insert into t2 values (1);<br />
Query OK, 1 row affected (0.09 sec)</p>
<p>mysql&gt; delete from t1.t1;<br />
ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (`t1`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`id`) REFERENCES `t1` (`id`))</p>
<p>So, it works for me.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
