<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>James Sapara's Personal Blog &#187; database</title>
	<atom:link href="http://blog.sapara.com/tag/database/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sapara.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Thu, 27 Oct 2011 22:01:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Database Design: 101</title>
		<link>http://blog.sapara.com/2008/11/20/database-design-101/</link>
		<comments>http://blog.sapara.com/2008/11/20/database-design-101/#comments</comments>
		<pubDate>Thu, 20 Nov 2008 17:09:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database schema]]></category>
		<category><![CDATA[enumerations]]></category>
		<category><![CDATA[rant]]></category>

		<guid isPermaLink="false">http://blog.sapara.com/?p=352</guid>
		<description><![CDATA[In my line of work, I see a lot of legacy databases. We often tasked with converting them to something more modern. My #1 gripe with some of our junior programs in this task is not converting fields to a more appropriate data type when this takes place. Two examples that I come across often. [...]]]></description>
			<content:encoded><![CDATA[<p>In my line of work, I see a lot of legacy databases. We often tasked with converting them to something more modern. My #1 gripe with some of our junior programs in this task is not converting fields to a more appropriate data type when this takes place. Two examples that I come across often.</p>
<p><span id="more-352"></span><strong>1. The boolean as anything but a boolean</strong></p>
<p>This happens frequently when people are moving from an access database to anything else. Access wasn&#8217;t exactly friendly with boolean values (thou, it was possible to make a boolean field as an int(1) ). At any rate, most people who designed access databases used a char(1) where the values where either &#8216;Y&#8217; or &#8216;N&#8217;. It&#8217;s an obvious mapping to a boolean. For whatever reason, people just leave these fields as the single character fields, instead of migrating it to a more friendly boolean field. So, that&#8217;s the first no-no of database design. Using anything but a boolean (or I&#8217;ll accept a bit field) for boolean values</p>
<p><strong>2. The complete avoidance of enumeration fields</strong></p>
<p>There are many cases when a field represents something like the status of an order: new, pending_payment, processed, shipped, complete. Often, I see these sorts of status as varchar fields. This is fine and dandy, except I have no idea what are acceptable values to put in the that column. I could do a select unique on it and hope that there is atleast one record representing each possible value, but that isn&#8217;t a reliable way to do it. One could argue the DBA would have documentation on what should go in there, or that the business logic would dictate it; but, most projects skip those points. Really, only the orgional programmer has any hope of remembering what can go in those fields, making them somewhat problematic to work with for future work.</p>
<p>In comes enumerations. Because you specify what the heck is valid in the field, you don&#8217;t have to guess what can possibly go in them. It&#8217;s actually their intended use. It also provides a form of feedback when you try to set that field to something your not expecting. Further preventing people from doing stuff like &#8220;New&#8221; vs &#8220;new&#8221; (which I have seen&#8230;).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sapara.com/2008/11/20/database-design-101/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

