<?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: Picking datatype for STATUS fields</title>
	<atom:link href="http://www.mysqlperformanceblog.com/2008/08/09/picking-datatype-for-status-feilds/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mysqlperformanceblog.com/2008/08/09/picking-datatype-for-status-feilds/</link>
	<description>Everything about MySQL Performance</description>
	<lastBuildDate>Sat, 21 Nov 2009 05:23:57 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Joe</title>
		<link>http://www.mysqlperformanceblog.com/2008/08/09/picking-datatype-for-status-feilds/comment-page-1/#comment-402986</link>
		<dc:creator>Joe</dc:creator>
		<pubDate>Sat, 06 Dec 2008 21:31:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=464#comment-402986</guid>
		<description>Awesome article, makes me want to go and check some of my older db designs to see how I was doing them.

For some time I&#039;ve been doing this: The status field is a TINYINT or INT(2). But to attack the problem of self documentation, I just create a table with  fields, and DBAs and DB users don&#039;t have to ask the dev team for the meaning of those numeric values. Heck, they can even make joins with this table to get an understandable query result.

What do you think of it?</description>
		<content:encoded><![CDATA[<p>Awesome article, makes me want to go and check some of my older db designs to see how I was doing them.</p>
<p>For some time I&#8217;ve been doing this: The status field is a TINYINT or INT(2). But to attack the problem of self documentation, I just create a table with  fields, and DBAs and DB users don&#8217;t have to ask the dev team for the meaning of those numeric values. Heck, they can even make joins with this table to get an understandable query result.</p>
<p>What do you think of it?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2008/08/09/picking-datatype-for-status-feilds/comment-page-1/#comment-346255</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Mon, 18 Aug 2008 23:43:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=464#comment-346255</guid>
		<description>Lukas,

In many cases you would see &quot;const&quot; join type for such tables which is very fast (because it is pre-read only once) however if it is join for each row it can get expensive even if data is in memory - join is still much slower than fetching data from the different column in same table.</description>
		<content:encoded><![CDATA[<p>Lukas,</p>
<p>In many cases you would see &#8220;const&#8221; join type for such tables which is very fast (because it is pre-read only once) however if it is join for each row it can get expensive even if data is in memory &#8211; join is still much slower than fetching data from the different column in same table.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Brunson</title>
		<link>http://www.mysqlperformanceblog.com/2008/08/09/picking-datatype-for-status-feilds/comment-page-1/#comment-346207</link>
		<dc:creator>Eric Brunson</dc:creator>
		<pubDate>Mon, 18 Aug 2008 20:32:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=464#comment-346207</guid>
		<description>Peter,

That&#039;s very good to know, thank you.

e.</description>
		<content:encoded><![CDATA[<p>Peter,</p>
<p>That&#8217;s very good to know, thank you.</p>
<p>e.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lukas</title>
		<link>http://www.mysqlperformanceblog.com/2008/08/09/picking-datatype-for-status-feilds/comment-page-1/#comment-346147</link>
		<dc:creator>Lukas</dc:creator>
		<pubDate>Mon, 18 Aug 2008 13:12:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=464#comment-346147</guid>
		<description>Just to take an even different look. On a current project using SQL server, the application developer I am designing the schema with prefers to use lookup tables for all of this.

A lookup table behaves more or less like ENUM with a few key differences:
- Its ease to add/remove entries (even reordering is possible without having to alter the db schema
- Obviously you end up having to do joins. However the lookup tables should obviously be super small and easily fit into memory</description>
		<content:encoded><![CDATA[<p>Just to take an even different look. On a current project using SQL server, the application developer I am designing the schema with prefers to use lookup tables for all of this.</p>
<p>A lookup table behaves more or less like ENUM with a few key differences:<br />
- Its ease to add/remove entries (even reordering is possible without having to alter the db schema<br />
- Obviously you end up having to do joins. However the lookup tables should obviously be super small and easily fit into memory</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2008/08/09/picking-datatype-for-status-feilds/comment-page-1/#comment-345955</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Mon, 18 Aug 2008 00:30:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=464#comment-345955</guid>
		<description>Thanks Dave for putting it to the log buffer :)</description>
		<content:encoded><![CDATA[<p>Thanks Dave for putting it to the log buffer <img src='http://www.mysqlperformanceblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2008/08/09/picking-datatype-for-status-feilds/comment-page-1/#comment-345954</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Mon, 18 Aug 2008 00:24:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=464#comment-345954</guid>
		<description>Eric,

Exception is raised in case you use &quot;strict&quot; mode. In traditional (default) mode MySQL is generally very permissive in value storage trying to make a best fit for the value.</description>
		<content:encoded><![CDATA[<p>Eric,</p>
<p>Exception is raised in case you use &#8220;strict&#8221; mode. In traditional (default) mode MySQL is generally very permissive in value storage trying to make a best fit for the value.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Brunson</title>
		<link>http://www.mysqlperformanceblog.com/2008/08/09/picking-datatype-for-status-feilds/comment-page-1/#comment-345931</link>
		<dc:creator>Eric Brunson</dc:creator>
		<pubDate>Sun, 17 Aug 2008 22:32:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=464#comment-345931</guid>
		<description>&quot;It is also worth to note ENUM comes with couple of gotchas - first if you store value which is not allowed by ENUM list it will be always converted to ” - empty string, the additional ENUM columns can have.&quot;

That is an implementation flaw in my opinion.  It should be similar to a FK violation and raise an exception.</description>
		<content:encoded><![CDATA[<p>&#8220;It is also worth to note ENUM comes with couple of gotchas &#8211; first if you store value which is not allowed by ENUM list it will be always converted to ” &#8211; empty string, the additional ENUM columns can have.&#8221;</p>
<p>That is an implementation flaw in my opinion.  It should be similar to a FK violation and raise an exception.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vahur</title>
		<link>http://www.mysqlperformanceblog.com/2008/08/09/picking-datatype-for-status-feilds/comment-page-1/#comment-345464</link>
		<dc:creator>Vahur</dc:creator>
		<pubDate>Sat, 16 Aug 2008 17:41:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=464#comment-345464</guid>
		<description>Nice article and especially &quot;the 1-bit trick is a CHAR(0) NULL&quot; from Baron Schwartz. I never thought about it like this.</description>
		<content:encoded><![CDATA[<p>Nice article and especially &#8220;the 1-bit trick is a CHAR(0) NULL&#8221; from Baron Schwartz. I never thought about it like this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2008/08/09/picking-datatype-for-status-feilds/comment-page-1/#comment-345157</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Sat, 16 Aug 2008 00:39:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=464#comment-345157</guid>
		<description>Thanks Roland,

Indeed this applies to standard behavior.  If you get to Strict mode it is going to be changed... but a lot of other stuff is going to change as well.   In most cases I&#039;ve seen enabling strict mode also needed a lot of minor fixes to the application to make it work :)</description>
		<content:encoded><![CDATA[<p>Thanks Roland,</p>
<p>Indeed this applies to standard behavior.  If you get to Strict mode it is going to be changed&#8230; but a lot of other stuff is going to change as well.   In most cases I&#8217;ve seen enabling strict mode also needed a lot of minor fixes to the application to make it work <img src='http://www.mysqlperformanceblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roland Bouman</title>
		<link>http://www.mysqlperformanceblog.com/2008/08/09/picking-datatype-for-status-feilds/comment-page-1/#comment-345099</link>
		<dc:creator>Roland Bouman</dc:creator>
		<pubDate>Fri, 15 Aug 2008 21:06:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=464#comment-345099</guid>
		<description>Hi Peter, 

nice post, thanks. Found one error though:

&quot;if you store value which is not allowed by ENUM list it will be always converted to ” - empty string&quot;

This is the case if your sql_mode does not include STRICT_TRANS_TABLES or STRICT_ALL_TABLES (which it doesn&#039;t by default). If it does include (or is equal to) these modes, value truncation due to inserting or updating a non-defined value will lead to a runtime error:

ERROR 1265 (01000): Data truncated for column &#039;%c&#039; at row %r

(Do you have any benchmark data on sql modes? would be interesting to know whether there is a performance penalty involved in one of these modes, or the more encompassing TRADITIONAL mode)

Roland</description>
		<content:encoded><![CDATA[<p>Hi Peter, </p>
<p>nice post, thanks. Found one error though:</p>
<p>&#8220;if you store value which is not allowed by ENUM list it will be always converted to ” &#8211; empty string&#8221;</p>
<p>This is the case if your sql_mode does not include STRICT_TRANS_TABLES or STRICT_ALL_TABLES (which it doesn&#8217;t by default). If it does include (or is equal to) these modes, value truncation due to inserting or updating a non-defined value will lead to a runtime error:</p>
<p>ERROR 1265 (01000): Data truncated for column &#8216;%c&#8217; at row %r</p>
<p>(Do you have any benchmark data on sql modes? would be interesting to know whether there is a performance penalty involved in one of these modes, or the more encompassing TRADITIONAL mode)</p>
<p>Roland</p>
]]></content:encoded>
	</item>
</channel>
</rss>
