<?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>Janusz Slota &#187; email</title>
	<atom:link href="http://janusz.slota.name/blog/tag/email/feed/" rel="self" type="application/rss+xml" />
	<link>http://janusz.slota.name/blog</link>
	<description>My home page</description>
	<lastBuildDate>Thu, 08 Dec 2011 09:56:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>What&#8217;s the average length of an email address?</title>
		<link>http://janusz.slota.name/blog/2009/05/email-length/</link>
		<comments>http://janusz.slota.name/blog/2009/05/email-length/#comments</comments>
		<pubDate>Tue, 05 May 2009 16:52:18 +0000</pubDate>
		<dc:creator>Janusz Słota</dc:creator>
				<category><![CDATA[Howto]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">http://janusz.slota.name/blog/?p=1</guid>
		<description><![CDATA[This question always comes up, when you have to design new table in database to store email addresses. Is VARCHAR(30) long enough? Or maybe you should use VARCHAR(255) or maybe TEXT as I&#8217;ve seen in some projects? My live database, which I&#8217;ve used for this test contains 92298 valid email addresses, verified with the Pear [...]]]></description>
			<content:encoded><![CDATA[<p>This question always comes up, when you have to design new table in database to store email addresses. Is <strong>VARCHAR(30)</strong> long enough? Or maybe you should use <strong>VARCHAR(255)</strong> or maybe <strong>TEXT</strong> as I&#8217;ve seen in some projects?</p>
<p>My live database, which I&#8217;ve used for this test contains <strong>92298</strong> valid email addresses, verified with the <a href="http://pear.php.net/package/Validate" target="_blank">Pear Validate</a> class with domain checking.<br />
<span id="more-1"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>Validate<span style="color: #339933;">::</span><span style="color: #004000;">email</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$email</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// add to database</span>
    <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// return error</span>
    <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>It means, if the email address is in this database &#8211; it is real and correct, otherwise the field is empty. So to make sure not to include empty fields, I&#8217;ve issued following query:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #993333; font-weight: bold;">COUNT</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #993333; font-weight: bold;">LENGTH</span><span style="color: #66cc66;">&#40;</span>email<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #993333; font-weight: bold;">SIZE</span> <span style="color: #993333; font-weight: bold;">FROM</span> customer <span style="color: #993333; font-weight: bold;">WHERE</span> email <span style="color: #993333; font-weight: bold;">LIKE</span> <span style="color: #ff0000;">'%@%'</span> <span style="color: #993333; font-weight: bold;">GROUP</span> <span style="color: #993333; font-weight: bold;">BY</span> <span style="color: #993333; font-weight: bold;">SIZE</span> <span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> <span style="color: #993333; font-weight: bold;">SIZE</span>;</pre></div></div>

<p>This query returns set of values, which I&#8217;ve used to create this chart (with <a title="OpenOffice.org" href="http://openoffice.org" target="_blank">OpenOffice.org</a> Calc).</p>
<p style="text-align: center;"><img class="size-full wp-image-12 aligncenter" title="Average emial address length" src="http://janusz.slota.name/blog/wp-content/uploads/2009/05/email-length-stats_html_54813cd4.jpg" alt="email-length-stats_html_54813cd4" width="815" height="241" /></p>
<p>As you can see majority of email addresses are around 13 to 34 characters long. To store email addresses I&#8217;ve used <strong>VARCHAR (255)</strong> but as you can see <strong>VARCHAR(50)</strong> is enough.</p>
<p>The answer: <strong>VARCHAR(50)</strong> should do.</p>
]]></content:encoded>
			<wfw:commentRss>http://janusz.slota.name/blog/2009/05/email-length/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

