<?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/"
	xmlns:series="http://unfoldingneurons.com/"
		>
<channel>
	<title>Comments on: Why You Should Replace ENUM With Something Else</title>
	<atom:link href="http://www.brandonsavage.net/why-you-should-replace-enum-with-something-else/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.brandonsavage.net/why-you-should-replace-enum-with-something-else/</link>
	<description>The personal blog of Brandon Savage. Contains entries of a personal and professional nature focusing on PHP, Apple, LAMP, MySQL and Washington, DC.</description>
	<lastBuildDate>Fri, 03 Feb 2012 19:36:33 -0500</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Ryan</title>
		<link>http://www.brandonsavage.net/why-you-should-replace-enum-with-something-else/#comment-2421</link>
		<dc:creator>Ryan</dc:creator>
		<pubDate>Mon, 30 Nov 2009 23:47:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=1047#comment-2421</guid>
		<description>Also, this article suggests I use enums over varchars:

http://net.tutsplus.com/tutorials/other/top-20-mysql-best-practices/

Who to believe? I dare say it&#039;s different in each situation, hence the need for a good DBA. :)</description>
		<content:encoded><![CDATA[<p>Also, this article suggests I use enums over varchars:</p>
<p><a href="http://net.tutsplus.com/tutorials/other/top-20-mysql-best-practices/" rel="nofollow">http://net.tutsplus.com/tutorials/other/top-20-mysql-best-practices/</a></p>
<p>Who to believe? I dare say it&#8217;s different in each situation, hence the need for a good DBA. :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan</title>
		<link>http://www.brandonsavage.net/why-you-should-replace-enum-with-something-else/#comment-2420</link>
		<dc:creator>Ryan</dc:creator>
		<pubDate>Mon, 30 Nov 2009 23:21:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=1047#comment-2420</guid>
		<description>I agree with Vid about #3: &quot;3. Sometimes, you do need the database to hande to handle constraints, foreign keys, enums etc, because you can not guarantee that the only way to access the database is going to be through your application.&quot;

I&#039;ve actually had problems of bad values in a database because Doctrine uses varchars and I did a whole lot of bulk operations with raw queries. Granted, it was an easy problem to fix and didn&#039;t do any damage, but it was a bit of a pain.

Of course, it&#039;s also been really nice to only have to update the application instead of a bunch of development and live databases.</description>
		<content:encoded><![CDATA[<p>I agree with Vid about #3: &#8220;3. Sometimes, you do need the database to hande to handle constraints, foreign keys, enums etc, because you can not guarantee that the only way to access the database is going to be through your application.&#8221;</p>
<p>I&#8217;ve actually had problems of bad values in a database because Doctrine uses varchars and I did a whole lot of bulk operations with raw queries. Granted, it was an easy problem to fix and didn&#8217;t do any damage, but it was a bit of a pain.</p>
<p>Of course, it&#8217;s also been really nice to only have to update the application instead of a bunch of development and live databases.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon</title>
		<link>http://www.brandonsavage.net/why-you-should-replace-enum-with-something-else/#comment-2418</link>
		<dc:creator>Jon</dc:creator>
		<pubDate>Mon, 30 Nov 2009 19:56:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=1047#comment-2418</guid>
		<description>I don&#039;t think that it&#039;s wise to follow a developer&#039;s opinion on DB design models.  As on the MySQL DB forums for suggestions.  Developers can only give you what a developer understands.  DBA&#039;s can give you a better understanding of when/where to use specific MySQL field types.  If ENUM is in MySQL&#039;s core functionality, it&#039;s obviously useful.  Otherwise, I tend to think that they would be smart enough to drop it and consider it obsolete...</description>
		<content:encoded><![CDATA[<p>I don&#8217;t think that it&#8217;s wise to follow a developer&#8217;s opinion on DB design models.  As on the MySQL DB forums for suggestions.  Developers can only give you what a developer understands.  DBA&#8217;s can give you a better understanding of when/where to use specific MySQL field types.  If ENUM is in MySQL&#8217;s core functionality, it&#8217;s obviously useful.  Otherwise, I tend to think that they would be smart enough to drop it and consider it obsolete&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rijk van Wel</title>
		<link>http://www.brandonsavage.net/why-you-should-replace-enum-with-something-else/#comment-2309</link>
		<dc:creator>Rijk van Wel</dc:creator>
		<pubDate>Thu, 26 Nov 2009 14:46:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=1047#comment-2309</guid>
		<description>Hi Brandon, interesting post, however you didn&#039;t consider the fact that ENUM columns use integer values internally (like Jase mentioned earlier), which is a lot more effectient when storing and selecting in certain fixed sets of string values (like &#039;male&#039; or &#039;female&#039;). 

I was wondering what the alternative was you had in mind - since I don&#039;t think varchar is a suitable replacement in these cases?</description>
		<content:encoded><![CDATA[<p>Hi Brandon, interesting post, however you didn&#8217;t consider the fact that ENUM columns use integer values internally (like Jase mentioned earlier), which is a lot more effectient when storing and selecting in certain fixed sets of string values (like &#8216;male&#8217; or &#8216;female&#8217;). </p>
<p>I was wondering what the alternative was you had in mind &#8211; since I don&#8217;t think varchar is a suitable replacement in these cases?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Les</title>
		<link>http://www.brandonsavage.net/why-you-should-replace-enum-with-something-else/#comment-2295</link>
		<dc:creator>Les</dc:creator>
		<pubDate>Wed, 25 Nov 2009 19:56:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=1047#comment-2295</guid>
		<description>I wouldn&#039;t say the database backend is part of the model either - just like using web services (a good comparison to your database) would not be considered part of your model.</description>
		<content:encoded><![CDATA[<p>I wouldn&#8217;t say the database backend is part of the model either &#8211; just like using web services (a good comparison to your database) would not be considered part of your model.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jase</title>
		<link>http://www.brandonsavage.net/why-you-should-replace-enum-with-something-else/#comment-2292</link>
		<dc:creator>Jase</dc:creator>
		<pubDate>Wed, 25 Nov 2009 15:08:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=1047#comment-2292</guid>
		<description>Oops, meant:

SELECT enum_column FROM table WHERE enum_column=1; # gives you 0

SELECT enum_column FROM table WHERE enum_column=’1′; # gives you 1</description>
		<content:encoded><![CDATA[<p>Oops, meant:</p>
<p>SELECT enum_column FROM table WHERE enum_column=1; # gives you 0</p>
<p>SELECT enum_column FROM table WHERE enum_column=’1′; # gives you 1</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Krzysztof Kotowicz</title>
		<link>http://www.brandonsavage.net/why-you-should-replace-enum-with-something-else/#comment-2291</link>
		<dc:creator>Krzysztof Kotowicz</dc:creator>
		<pubDate>Wed, 25 Nov 2009 15:04:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=1047#comment-2291</guid>
		<description>@Pádraic

I&#039;m not saying that you should skip validation in your application code. I replied to this Brandon&#039;s statement: &quot;The model should be enforcing the constraints on the data types and values going into your database, not the database itself&quot;. What I think is that DB _must_ enforce its own constraints (eg. by using FK constraints, check constraints where it would be applicable) and should not rely that application always submits consistent data. 

High level checking is needed, I agree completely. However, I don&#039;t think that &quot;the database itself&quot; is not the place for constraints - exactly the opposite. If you don&#039;t enforce the constraints at the lowest possible layer, you can end up with incosinstent data because application code was e.g. buggy, the connection dropped, there was a security hole in application etc. To compare that - it&#039;s like having a Javascript validation on a client and skipping it server-side. Would anyone recommend it?</description>
		<content:encoded><![CDATA[<p>@Pádraic</p>
<p>I&#8217;m not saying that you should skip validation in your application code. I replied to this Brandon&#8217;s statement: &#8220;The model should be enforcing the constraints on the data types and values going into your database, not the database itself&#8221;. What I think is that DB _must_ enforce its own constraints (eg. by using FK constraints, check constraints where it would be applicable) and should not rely that application always submits consistent data. </p>
<p>High level checking is needed, I agree completely. However, I don&#8217;t think that &#8220;the database itself&#8221; is not the place for constraints &#8211; exactly the opposite. If you don&#8217;t enforce the constraints at the lowest possible layer, you can end up with incosinstent data because application code was e.g. buggy, the connection dropped, there was a security hole in application etc. To compare that &#8211; it&#8217;s like having a Javascript validation on a client and skipping it server-side. Would anyone recommend it?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jase</title>
		<link>http://www.brandonsavage.net/why-you-should-replace-enum-with-something-else/#comment-2290</link>
		<dc:creator>Jase</dc:creator>
		<pubDate>Wed, 25 Nov 2009 14:47:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=1047#comment-2290</guid>
		<description>Worrying about how enums sort should be a non-issue, since you should NEVER SORT IN MySQL. This is because ORDER BY will usually cause the query to dump to disk, especially if you are working with millions of records. Instead, set a high enough memory_limit, dump data with mysql_buffered_query, and dump into multi-dimensional arrays so they can be more easily sorted in PHP. Much, much faster.

With that in mind, enums are great if you use them for a set of values that is too small for a separate table and likely to be used too widely to be enforced in logic. Inserting new enum values in the middle may rebuild the table, and with millions of records this could pose a small problem, but the real problem would be if you were using lots of enums (they allow 65,000+ values) and rebuilding millions of records.

The truly funky thing with enums are that they are basically 1-based arrays. If you define ENUM(&#039;0&#039;, &#039;1&#039;, &#039;2&#039;), the indexes are 1,2,3, and you can SELECT using the index. The following queries show what happens if you forget quotes:

SELECT enum_column FROM table WHERE enum_column=1; # gives you 2

SELECT enum_column FROM table WHERE enum_column=&#039;1&#039;; # gives you 1

Also, they are sorted by this numeric index, and so that is why they do not sort by alpha.</description>
		<content:encoded><![CDATA[<p>Worrying about how enums sort should be a non-issue, since you should NEVER SORT IN MySQL. This is because ORDER BY will usually cause the query to dump to disk, especially if you are working with millions of records. Instead, set a high enough memory_limit, dump data with mysql_buffered_query, and dump into multi-dimensional arrays so they can be more easily sorted in PHP. Much, much faster.</p>
<p>With that in mind, enums are great if you use them for a set of values that is too small for a separate table and likely to be used too widely to be enforced in logic. Inserting new enum values in the middle may rebuild the table, and with millions of records this could pose a small problem, but the real problem would be if you were using lots of enums (they allow 65,000+ values) and rebuilding millions of records.</p>
<p>The truly funky thing with enums are that they are basically 1-based arrays. If you define ENUM(&#8217;0&#8242;, &#8217;1&#8242;, &#8217;2&#8242;), the indexes are 1,2,3, and you can SELECT using the index. The following queries show what happens if you forget quotes:</p>
<p>SELECT enum_column FROM table WHERE enum_column=1; # gives you 2</p>
<p>SELECT enum_column FROM table WHERE enum_column=&#8217;1&#8242;; # gives you 1</p>
<p>Also, they are sorted by this numeric index, and so that is why they do not sort by alpha.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vid Luther</title>
		<link>http://www.brandonsavage.net/why-you-should-replace-enum-with-something-else/#comment-2289</link>
		<dc:creator>Vid Luther</dc:creator>
		<pubDate>Wed, 25 Nov 2009 14:47:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=1047#comment-2289</guid>
		<description>I think the post should be renamed to &quot;How to use ENUMs the wrong way&quot;.. 

1. MySQL 5.4/6.0 will have online capabilities, so the issue of ALTER tables taking too long will go away, an argument against something, should either be prefaced by a version #, or should stand the test of time.

2. Adding ENUM&#039;s to the middle is indicative of a flaw in logic on the DBA/Programmers part, not the data type. 

3. Sometimes, you do need the database to hande to handle constraints, foreign keys, enums etc, because you can not guarantee that the only way to access the database is going to be through your application. 

4. The only reason not to use ENUM, is if you think you&#039;ll be changing databases, and even then, you don&#039;t switch your PDO DSN, you think through a lot of stuff before you make the change, and you should have a migration path.</description>
		<content:encoded><![CDATA[<p>I think the post should be renamed to &#8220;How to use ENUMs the wrong way&#8221;.. </p>
<p>1. MySQL 5.4/6.0 will have online capabilities, so the issue of ALTER tables taking too long will go away, an argument against something, should either be prefaced by a version #, or should stand the test of time.</p>
<p>2. Adding ENUM&#8217;s to the middle is indicative of a flaw in logic on the DBA/Programmers part, not the data type. </p>
<p>3. Sometimes, you do need the database to hande to handle constraints, foreign keys, enums etc, because you can not guarantee that the only way to access the database is going to be through your application. </p>
<p>4. The only reason not to use ENUM, is if you think you&#8217;ll be changing databases, and even then, you don&#8217;t switch your PDO DSN, you think through a lot of stuff before you make the change, and you should have a migration path.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pádraic Brady</title>
		<link>http://www.brandonsavage.net/why-you-should-replace-enum-with-something-else/#comment-2288</link>
		<dc:creator>Pádraic Brady</dc:creator>
		<pubDate>Wed, 25 Nov 2009 13:20:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=1047#comment-2288</guid>
		<description>@Krzysztof The database is NOT part of the model. It is a storage backend for the model. You can use constraints in the database for data integrity, but that is the storage design. The Model will perform its own high level checking and normalise retrieved data to an understandable form.

As for PHP/.NET etc operating on the same database - the reality is their Model still needs to be developed anyway. If there&#039;s duplication there, someone needs to ask why there are two languages in use creating this consequence. (Usually it&#039;s for obvious reasons - PHP as a frontend, something else in the back - they will duplicate Models somewhat if operating on similar data).

A lot of this is why ENUMs are somewhat sensitive. They are a database construct - not a programming one. Since many of us use ORMs and design Models from a top-down perspective, they tend not to get much traction everywhere. Personally I use them only rarely - my Models will handle Enum like properties internally and just use a varchar to store the value. Enums are by no means a necessity in modelling. Their main justification would lie in performance - assuming such is measurable. Most apps won&#039;t bother...

Note: In case nobody has noticed, when using an ORM most of this is perfectly pointless ;). If you do not use an ORM and write your own SQL, well I&#039;m sure Enums are great at that level. Just be aware that it all depends at what level you are designing from.</description>
		<content:encoded><![CDATA[<p>@Krzysztof The database is NOT part of the model. It is a storage backend for the model. You can use constraints in the database for data integrity, but that is the storage design. The Model will perform its own high level checking and normalise retrieved data to an understandable form.</p>
<p>As for PHP/.NET etc operating on the same database &#8211; the reality is their Model still needs to be developed anyway. If there&#8217;s duplication there, someone needs to ask why there are two languages in use creating this consequence. (Usually it&#8217;s for obvious reasons &#8211; PHP as a frontend, something else in the back &#8211; they will duplicate Models somewhat if operating on similar data).</p>
<p>A lot of this is why ENUMs are somewhat sensitive. They are a database construct &#8211; not a programming one. Since many of us use ORMs and design Models from a top-down perspective, they tend not to get much traction everywhere. Personally I use them only rarely &#8211; my Models will handle Enum like properties internally and just use a varchar to store the value. Enums are by no means a necessity in modelling. Their main justification would lie in performance &#8211; assuming such is measurable. Most apps won&#8217;t bother&#8230;</p>
<p>Note: In case nobody has noticed, when using an ORM most of this is perfectly pointless ;). If you do not use an ORM and write your own SQL, well I&#8217;m sure Enums are great at that level. Just be aware that it all depends at what level you are designing from.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Krzysztof Kotowicz</title>
		<link>http://www.brandonsavage.net/why-you-should-replace-enum-with-something-else/#comment-2287</link>
		<dc:creator>Krzysztof Kotowicz</dc:creator>
		<pubDate>Wed, 25 Nov 2009 12:46:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=1047#comment-2287</guid>
		<description>I totally dissagree, Brandon. As Ben pointed out, one could argue against ENUMs because they are MySQL-specific, but your points are just incorrect in my opinion. 

First agrument (adding to middle of the set) - who would want that? It&#039;s an enumeration, you don&#039;t sort by it. Exemplary enumeration is CLUB, DIAMOND, HEART, SPADE (thats&#039;s from http://en.wikipedia.org/wiki/Enumerated_type) - is diamond greater than club? You can&#039;t tell so you shouldn&#039;t order by it (unless you only want to show clubs next to clubs, spades next to spades etc.)

Second - &quot;ENUM values are ordered in the order they’re added to the database&quot;. Yes, they are. Just like AUTO_INCREMENT fields. If you used (instead of ENUMs) an additional dictionary table
and put a foreign key into the main table, it would still bite you - primary key in the dictionary table would most likely be auto incremented and you couldn&#039;t add a value to the middle of the set or change the order without touching the main table. 

If you wan&#039;t to manipulate the order of ENUMs - you are using them wrong, it&#039;s not the case against ENUMs.

&#039;ENUM values do in the database what should be done in the model&#039; - I&#039;m sorry but I just dissagree, database IS a part of a model - it&#039;s been built for exactly this purpose. You have data types, foreign keys, constraints, triggers, stored procedures, indexes - all of this is to manage persistent data. If you want to throw it out the window and try to enforce this in application layer only, you will end up writing SQL logic in PHP. Also, a single PHP application might not be the only consumer of this data - what if there is a .NET application, a Perl script or whatever which also accesses the data in your DB? You need to port the same constraints to these clients. And maintain in for the future. 

My experience tells me that what could go into database layer, probably should go there. It&#039;s compiled, optimized, it keeps the data integrity at the lowest possible level.

Of course I&#039;m not saying you should transfer all business logic to DB or totally skip the validation in application level. For sure though, constraints must be managed by the database or you can easily end up with inconsistent data.</description>
		<content:encoded><![CDATA[<p>I totally dissagree, Brandon. As Ben pointed out, one could argue against ENUMs because they are MySQL-specific, but your points are just incorrect in my opinion. </p>
<p>First agrument (adding to middle of the set) &#8211; who would want that? It&#8217;s an enumeration, you don&#8217;t sort by it. Exemplary enumeration is CLUB, DIAMOND, HEART, SPADE (thats&#8217;s from <a href="http://en.wikipedia.org/wiki/Enumerated_type" rel="nofollow">http://en.wikipedia.org/wiki/Enumerated_type</a>) &#8211; is diamond greater than club? You can&#8217;t tell so you shouldn&#8217;t order by it (unless you only want to show clubs next to clubs, spades next to spades etc.)</p>
<p>Second &#8211; &#8220;ENUM values are ordered in the order they’re added to the database&#8221;. Yes, they are. Just like AUTO_INCREMENT fields. If you used (instead of ENUMs) an additional dictionary table<br />
and put a foreign key into the main table, it would still bite you &#8211; primary key in the dictionary table would most likely be auto incremented and you couldn&#8217;t add a value to the middle of the set or change the order without touching the main table. </p>
<p>If you wan&#8217;t to manipulate the order of ENUMs &#8211; you are using them wrong, it&#8217;s not the case against ENUMs.</p>
<p>&#8216;ENUM values do in the database what should be done in the model&#8217; &#8211; I&#8217;m sorry but I just dissagree, database IS a part of a model &#8211; it&#8217;s been built for exactly this purpose. You have data types, foreign keys, constraints, triggers, stored procedures, indexes &#8211; all of this is to manage persistent data. If you want to throw it out the window and try to enforce this in application layer only, you will end up writing SQL logic in PHP. Also, a single PHP application might not be the only consumer of this data &#8211; what if there is a .NET application, a Perl script or whatever which also accesses the data in your DB? You need to port the same constraints to these clients. And maintain in for the future. </p>
<p>My experience tells me that what could go into database layer, probably should go there. It&#8217;s compiled, optimized, it keeps the data integrity at the lowest possible level.</p>
<p>Of course I&#8217;m not saying you should transfer all business logic to DB or totally skip the validation in application level. For sure though, constraints must be managed by the database or you can easily end up with inconsistent data.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Les</title>
		<link>http://www.brandonsavage.net/why-you-should-replace-enum-with-something-else/#comment-2286</link>
		<dc:creator>Les</dc:creator>
		<pubDate>Wed, 25 Nov 2009 12:45:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=1047#comment-2286</guid>
		<description>&gt; ... developers drop the use of ENUM and use something else
&gt; instead ...

Such as? 

There is no other reasonable alternative - that is why we have ENUM and SET in the first -beep- place.

Been using them for a number of years and I will continue to use them. This whole arguement about using them or not comes not from a database design point of view but an ORM point of view.

You can shove your ORMs where the sun ain&#039;t going to shine if you ask me. I&#039;m not going to use something else that would break the rules of database normalisation.

Most of the time I agree with you but this arguement I can&#039;t.</description>
		<content:encoded><![CDATA[<p>&gt; &#8230; developers drop the use of ENUM and use something else<br />
&gt; instead &#8230;</p>
<p>Such as? </p>
<p>There is no other reasonable alternative &#8211; that is why we have ENUM and SET in the first -beep- place.</p>
<p>Been using them for a number of years and I will continue to use them. This whole arguement about using them or not comes not from a database design point of view but an ORM point of view.</p>
<p>You can shove your ORMs where the sun ain&#8217;t going to shine if you ask me. I&#8217;m not going to use something else that would break the rules of database normalisation.</p>
<p>Most of the time I agree with you but this arguement I can&#8217;t.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: FractalizeR</title>
		<link>http://www.brandonsavage.net/why-you-should-replace-enum-with-something-else/#comment-2285</link>
		<dc:creator>FractalizeR</dc:creator>
		<pubDate>Wed, 25 Nov 2009 11:34:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=1047#comment-2285</guid>
		<description>I disagree.

&quot;ENUM requires a rebuild of the table when adding a value to the middle of the set.&quot;
I see no reason of adding an enum value to the middle of the set. Nothing prevents you from adding it to the end.

&quot;ENUM values are ordered in the order they’re added to the database&quot;
I don&#039;t see any reason of ordering a table by ENUM also. ENUM is an enumeration and if you need to sort a table by it, that means, you chose a bad type for this value.

&quot;ENUM values do in the database what should be done in the model.&quot;
&quot;The model should be enforcing the constraints on the data types and values going into your database, not the database itself&quot;

I just disagree. If we take this point, we don&#039;t need, for example, foreign keys also because this database restriction can be applied by model.</description>
		<content:encoded><![CDATA[<p>I disagree.</p>
<p>&#8220;ENUM requires a rebuild of the table when adding a value to the middle of the set.&#8221;<br />
I see no reason of adding an enum value to the middle of the set. Nothing prevents you from adding it to the end.</p>
<p>&#8220;ENUM values are ordered in the order they’re added to the database&#8221;<br />
I don&#8217;t see any reason of ordering a table by ENUM also. ENUM is an enumeration and if you need to sort a table by it, that means, you chose a bad type for this value.</p>
<p>&#8220;ENUM values do in the database what should be done in the model.&#8221;<br />
&#8220;The model should be enforcing the constraints on the data types and values going into your database, not the database itself&#8221;</p>
<p>I just disagree. If we take this point, we don&#8217;t need, for example, foreign keys also because this database restriction can be applied by model.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brandon Savage</title>
		<link>http://www.brandonsavage.net/why-you-should-replace-enum-with-something-else/#comment-2284</link>
		<dc:creator>Brandon Savage</dc:creator>
		<pubDate>Wed, 25 Nov 2009 11:24:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=1047#comment-2284</guid>
		<description>Jan!, to address your last point, making use of the integer versus varchar data types makes doing math in the database easier, and using the proper data type saves bytes and more importantly, time. MySQL will switch types for you (e.g. if you have an integer but insert a value surrounded by quotes it will cast it to an integer), but this takes the system time.

Bruce, there&#039;s an argument to be made either way. Storing .25 in the database is proper for doing math, but the data must be manipulated in two ways in order to be displayed: it must be multiplied by 100 (to make it a whole number), and then it must be given a % symbol on the end. I think the view can handle adding the percent symbol, but the manipulation of the data should take place in the model - even if it&#039;s just as simple as multiplying the value by 100. Still, I think we&#039;re arguing semantics here, rather than addressing the core issue, which is that the database stores data, and the model manipulates it.</description>
		<content:encoded><![CDATA[<p>Jan!, to address your last point, making use of the integer versus varchar data types makes doing math in the database easier, and using the proper data type saves bytes and more importantly, time. MySQL will switch types for you (e.g. if you have an integer but insert a value surrounded by quotes it will cast it to an integer), but this takes the system time.</p>
<p>Bruce, there&#8217;s an argument to be made either way. Storing .25 in the database is proper for doing math, but the data must be manipulated in two ways in order to be displayed: it must be multiplied by 100 (to make it a whole number), and then it must be given a % symbol on the end. I think the view can handle adding the percent symbol, but the manipulation of the data should take place in the model &#8211; even if it&#8217;s just as simple as multiplying the value by 100. Still, I think we&#8217;re arguing semantics here, rather than addressing the core issue, which is that the database stores data, and the model manipulates it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bruce Weirdan</title>
		<link>http://www.brandonsavage.net/why-you-should-replace-enum-with-something-else/#comment-2283</link>
		<dc:creator>Bruce Weirdan</dc:creator>
		<pubDate>Wed, 25 Nov 2009 10:19:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=1047#comment-2283</guid>
		<description>&quot;The model is the domain logic which takes the raw data and turns it into data that the application uses. For example, you may store 0.25 in the database but convert that to 25% when you display it in your view; it’s not stored as 25% in the database, though.&quot;
Bad example - number formatting is a task for view, not the model.</description>
		<content:encoded><![CDATA[<p>&#8220;The model is the domain logic which takes the raw data and turns it into data that the application uses. For example, you may store 0.25 in the database but convert that to 25% when you display it in your view; it’s not stored as 25% in the database, though.&#8221;<br />
Bad example &#8211; number formatting is a task for view, not the model.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic (Feed is rejected)
Page Caching using disk: enhanced (User agent is rejected)
Database Caching using disk: basic
Content Delivery Network via Amazon Web Services: S3: files.brandonsavage.net.s3.amazonaws.com

Served from: www.brandonsavage.net @ 2012-02-07 05:05:23 -->
