<?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>String Functions &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/string-functions/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Mon, 20 Nov 2017 05:48:08 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.6</generator>
	<item>
		<title>Effective storage of Email Address into Database System</title>
		<link>https://www.dbrnd.com/2015/05/effective-storage-of-email-address-into/</link>
					<comments>https://www.dbrnd.com/2015/05/effective-storage-of-email-address-into/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Tue, 19 May 2015 13:23:10 +0000</pubDate>
				<category><![CDATA[Database Designing]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[Database Design]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[Email Address]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[MySQL Database Administrator]]></category>
		<category><![CDATA[MySQL Query]]></category>
		<category><![CDATA[Storage]]></category>
		<category><![CDATA[String Functions]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=125</guid>

					<description><![CDATA[Problem : Email Address is a ubiquitous field and column for every application or system. As per the application size and scope database system stores lots of user Email Addresses. E.g. 10,00,000 email address is stored in a database system and it is also increasing day by day. Usually, any database user saves all this [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F05%2Feffective-storage-of-email-address-into%2F&amp;linkname=Effective%20storage%20of%20Email%20Address%20into%20Database%20System" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F05%2Feffective-storage-of-email-address-into%2F&amp;linkname=Effective%20storage%20of%20Email%20Address%20into%20Database%20System" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F05%2Feffective-storage-of-email-address-into%2F&amp;linkname=Effective%20storage%20of%20Email%20Address%20into%20Database%20System" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F05%2Feffective-storage-of-email-address-into%2F&amp;linkname=Effective%20storage%20of%20Email%20Address%20into%20Database%20System" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F05%2Feffective-storage-of-email-address-into%2F&amp;linkname=Effective%20storage%20of%20Email%20Address%20into%20Database%20System" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F05%2Feffective-storage-of-email-address-into%2F&amp;linkname=Effective%20storage%20of%20Email%20Address%20into%20Database%20System" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F05%2Feffective-storage-of-email-address-into%2F&#038;title=Effective%20storage%20of%20Email%20Address%20into%20Database%20System" data-a2a-url="https://www.dbrnd.com/2015/05/effective-storage-of-email-address-into/" data-a2a-title="Effective storage of Email Address into Database System"></a></p><p><b>Problem :</b></p>
<p>Email Address is a ubiquitous field and column for every application or system. As per the application size and scope database system stores lots of user Email Addresses.</p>
<p>E.g. 10,00,000 email address is stored in a database system and it is also increasing day by day.<br />
Usually, any database user saves all this email address into one column. Most probably there is one column name is EmailAddress Varchar(250)  and user store email address like &#8221; myprofile@yahoo.co.in &#8221; into this column. &#8211; Great and usually 70% to 75% user doing this.</p>
<p>Once database size and number of users are going to increase day by day at that time, this storage will not perform as per expectation and decrease the performance of the database.</p>
<p><b>How this will decrease the performance of the database?</b></p>
<ul>
<li>As we assumed that email address stored into one column like &#8221; myprofile@yahoo.co.in&#8221;.</li>
<li>Now, we require to find that, how many total numbers of users from only &#8220;Yahoo&#8221;  domain?</li>
<li>How many total number of users from only &#8220;India Yahoo&#8221;?</li>
<li>Require to set some additional offer only for &#8220;Gmail&#8221; domain.</li>
</ul>
<p>Friends, now think about above questions.</p>
<blockquote><p>In my career path I have also stored email address into one column, but gradually I came to know that this is a bad idea because now a day Email address is not only for user name or only for storage purpose.<br />
This is very important for promotional and marketing activity.</p></blockquote>
<p>When you have stored in one column and let&#8217;s imagine, you want to find only &#8221; Gmail &#8221; domain out of 10,0,00,000 email address. </p>
<p>As a database developer, you can think that you require one string operation on all stored email address in which you will find the part which is after  @&#8221;. But this is not a solution where string searching and parsing is required, which slows down the performance of relevant select statement.</p>
<p><b>Solution :</b><br />
The solution is simple,</p>
<p>Just divide your Email address into two part or three part.</p>
<p>E.g.</p>
<ul>
<li>Single Part : &#8221; myprofile@yahoo.co.in &#8220;.</li>
<li>Two Part : &#8221; myprofile&#8221; and &#8221; yahoo.co.in &#8220;.</li>
<li>Three Part : &#8220;myprofile&#8221; and &#8221; yahoo &#8221; and &#8221; co.in &#8220;.</li>
</ul>
<p><b>Now, I am going to explain this using one MySQL Demo. </b><br />
<a href="https://www.dbrnd.com/wp-content/uploads/2015/05/UserEmailRelation.png"><img fetchpriority="high" decoding="async" class=" wp-image-127 size-full aligncenter" title="User Email Relation" src="https://www.dbrnd.com/wp-content/uploads/2015/05/UserEmailRelation.png" alt="UserEmailRelation" width="359" height="145" srcset="https://www.dbrnd.com/wp-content/uploads/2015/05/UserEmailRelation.png 359w, https://www.dbrnd.com/wp-content/uploads/2015/05/UserEmailRelation-300x121.png 300w, https://www.dbrnd.com/wp-content/uploads/2015/05/UserEmailRelation-150x61.png 150w" sizes="(max-width: 359px) 100vw, 359px" /></a></p>
<p>I have created above two table into MySQL. I have divided Email Address into three part.<br />
Below is a sample data.<br />
<b>tbl_User table Data:</b><br />
<a href="https://www.dbrnd.com/wp-content/uploads/2015/05/UserMaster.png"><img decoding="async" class=" wp-image-128 size-full aligncenter" title="User Master" src="https://www.dbrnd.com/wp-content/uploads/2015/05/UserMaster.png" alt="User Master" width="386" height="81" srcset="https://www.dbrnd.com/wp-content/uploads/2015/05/UserMaster.png 386w, https://www.dbrnd.com/wp-content/uploads/2015/05/UserMaster-300x63.png 300w" sizes="(max-width: 386px) 100vw, 386px" /></a><b>tbl_Email table Data:</b><br />
<a href="https://www.dbrnd.com/wp-content/uploads/2015/05/EmailMaster.png"><img decoding="async" class="aligncenter wp-image-129 size-full" title="Email Master" src="https://www.dbrnd.com/wp-content/uploads/2015/05/EmailMaster.png" alt="Email Master" width="290" height="81" /></a></p>
<p><strong>Examine the first email address:</strong></p>
<blockquote><p>User Anvesh has anvesh@gmail.com, Roy has roy@yahoo.co.in<br />
As you can find the EmailDomainID reference column in, a User master table which is indicating that which email address is associated with User.<br />
Now a thing is going to easy:<br />
How ?</p></blockquote>
<p>If I require finding how many users with Gmail, I need to find the only EmailDomainID=1.</p>
<p>You can also apply easy extension filter like Yahoo from co.in and .com.<br />
This will give you 80% to 85% better performance than to store Email into one column.</p>
<blockquote><p><b>Also, This will reduce the size of data, E.g, if we store &#8221; Gmail &#8221; keyword 10,00,000 times into the database, then it consume more space than to store only integer &#8221; 1 &#8220;.</b></p></blockquote>
<p>Yes, I also agree that, during every insert, you have to split email address for storing purpose, but this is a good instead of parsing string to count only domain name.</p>
<p>This structure is quite complex to manage at every insert and every email existence check, but it gives better performance.</p>
<p>Below is simple string operation.</p>
<blockquote><p>Full Email Address is : anvesh@yahoo.co.in</p></blockquote>
<p><b>Now parse only &#8221; anvesh &#8221; from anvesh@yahoo.co.in</b></p><pre class="crayon-plain-tag">SELECT SUBSTRING
   ('anvesh@yahoo.CO.IN',1,
      (POSITION('@' IN 'anvesh@yahoo.CO.IN') -1)
   )</pre><p>
<b>Now parse only &#8221; yahoo &#8221; from anvesh@yahoo.co.in</b></p><pre class="crayon-plain-tag">SELECT SUBSTRING(
 SUBSTRING('anvesh@yahoo.CO.IN'
                ,(POSITION('@' IN 'anvesh@yahoo.CO.IN') + 1))
                ,1
                ,POSITION('.' IN SUBSTRING('anvesh@yahoo.CO.IN'
                      ,(POSITION('@' IN 'anvesh@yahoo.CO.IN')))
                         )-2
          )</pre><p>
<b>Now parse only &#8221; co.in &#8221; from anvesh@yahoo.co.in</b></p><pre class="crayon-plain-tag">SELECT SUBSTRING((SUBSTRING('anvesh@yahoo.CO.IN'
      ,(POSITION('@' IN 'anvesh@yahoo.CO.IN') + 1)))
      ,POSITION('.' IN SUBSTRING('anvesh@yahoo.CO.IN'
      ,(POSITION('@' IN 'anvesh@yahoo.CO.IN') + 1)))+1)</pre><p>
<blockquote><p>The above code is required whenever you insert the email address into the database because from the application end we receive one full email address, but for effective storage, you have to parse like above code. </p>
<p>You can also suggest three different input parameters from the application end where above all codes can shift to at application level.
</p></blockquote>
<p><b><a href="https://www.dbrnd.com/2015/05/mysql-string-functions/">Click here to find details about string functions of MySQL.</a></b></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2015/05/effective-storage-of-email-address-into/feed/</wfw:commentRss>
			<slash:comments>7</slash:comments>
		
		
			</item>
		<item>
		<title>MySQL String Functions</title>
		<link>https://www.dbrnd.com/2015/05/mysql-string-functions/</link>
					<comments>https://www.dbrnd.com/2015/05/mysql-string-functions/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Tue, 19 May 2015 12:53:57 +0000</pubDate>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[MySQL Command]]></category>
		<category><![CDATA[MySQL Database Administrator]]></category>
		<category><![CDATA[MySQL Database Programming]]></category>
		<category><![CDATA[MySQL Query]]></category>
		<category><![CDATA[String Example.]]></category>
		<category><![CDATA[String Functions]]></category>
		<category><![CDATA[String Parsing]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=113</guid>

					<description><![CDATA[In this post, I am sharing few essential string manipulation functions of MySQL. Below is a list of String functions with an example. CONCAT (Str1,Str2&#8230;):This function is used to concat two or more string and integer by passing a string or integer arguments. If you try to concat NULL with string, the result will be [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F05%2Fmysql-string-functions%2F&amp;linkname=MySQL%20String%20Functions" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F05%2Fmysql-string-functions%2F&amp;linkname=MySQL%20String%20Functions" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F05%2Fmysql-string-functions%2F&amp;linkname=MySQL%20String%20Functions" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F05%2Fmysql-string-functions%2F&amp;linkname=MySQL%20String%20Functions" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F05%2Fmysql-string-functions%2F&amp;linkname=MySQL%20String%20Functions" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F05%2Fmysql-string-functions%2F&amp;linkname=MySQL%20String%20Functions" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F05%2Fmysql-string-functions%2F&#038;title=MySQL%20String%20Functions" data-a2a-url="https://www.dbrnd.com/2015/05/mysql-string-functions/" data-a2a-title="MySQL String Functions"></a></p><p>In this post, I am sharing few essential string manipulation functions of MySQL. </p>
<p>Below is a list of String functions with an example.</p>
<div>
<p><b>CONCAT (Str1,Str2&#8230;):</b>This function is used to concat two or more string and integer by passing a string or integer arguments. If you try to concat NULL with string, the result will be NULL. You can also concat multiple arguments using a single function.</p>
</div>
<pre class="crayon-plain-tag">mysql&gt; SELECT CONCAT('String',' Function') AS CONCAT;
+-----------------+
| CONCAT          |
+-----------------+
| String Function |
+-----------------+

mysql&gt; SELECT CONCAT('String',' Function',' Demo') AS CONCAT;
+----------------------+
| CONCAT               |
+----------------------+
| String Function Demo |
+----------------------+

mysql&gt; SELECT CONCAT('String',' Function',null) AS CONCAT;
+--------+
| CONCAT |
+--------+
| NULL   |
+--------+

mysql&gt; SELECT CONCAT('String',' Function ',10) AS CONCAT;
+--------------------+
| CONCAT             |
+--------------------+
| String Function 10 |
+--------------------+</pre>
<p><b>LEFT (str,len):</b> This will return left most character from string and if you pass NULL argument, returns NULL result.</p><pre class="crayon-plain-tag">mysql&gt; SELECT LEFT ('String Function',5);

+----------------------------+
| LEFT ('String Function',5) |
+----------------------------+
| Strin                      |
+----------------------------+

mysql&gt; SELECT LEFT (15245,3);
+----------------+
| LEFT (15245,3) |
+----------------+
| 152            |
+----------------+</pre><p>
<p><b>RIGHT (str,len) :</b> This will return right most character from string and if you pass NULL argument, returns NULL result.</p><pre class="crayon-plain-tag">mysql&gt; SELECT RIGHT('String Function',5);

+----------------------------+
| RIGHT('String Function',5) |
+----------------------------+
| ction                      |
+----------------------------+</pre><p>
<p><b>INSTR (str,substr) :</b> This function is used to find starting position of given substring.</p>
<pre class="crayon-plain-tag">mysql&gt; SELECT INSTR('String Function','Fun');
+--------------------------------+
| INSTR('String Function','Fun') |
+--------------------------------+
|                              8 |
+--------------------------------+</pre>
<p><b>LOCATE (substr,str) :</b> This function work same as INSTR(str,substr)</p><pre class="crayon-plain-tag">mysql&gt; SELECT LOCATE('Fun','String Function');
+---------------------------------+
| LOCATE('Fun','String Function') |
+---------------------------------+
|                               8 |
+---------------------------------+</pre><p>
<p><b>POSITION (substr IN str) :</b> This function work same as INSTR(str,substr)</p>
<pre class="crayon-plain-tag">mysql&gt; SELECT POSITION('Fun' IN 'String Function');
+--------------------------------------+
| POSITION('Fun' IN 'String Function') |
+--------------------------------------+
|                                    8 |
+--------------------------------------+</pre>
<p><b>INSERT(str,pos,len,newstr) :</b> This function is used to overwrite new string part on an old string part.<br />
You require passing position and length to replace old part of string using the new part of a string.</p>
<pre class="crayon-plain-tag">mysql&gt; SELECT INSERT('String Function',7,4,'Demo');
+--------------------------------------+
| INSERT('String Function',7,4,'Demo') |
+--------------------------------------+
| StringDemoction                      |
+--------------------------------------+</pre>
<p><b>LENGTH(str):</b> This function is used to find length of given string.</p>
<pre class="crayon-plain-tag">mysql&gt; SELECT LENGTH('String Function');
+---------------------------+
| LENGTH('String Function') |
+---------------------------+
|                        15 |
+---------------------------+</pre>
<p><b>UPPER(str) / LOWER(str) :</b> This both function is used to change string from lower to upper or upper to lowar case.</p>
<pre class="crayon-plain-tag">mysql&gt; SELECT LOWER('FUNCTION');
+-------------------+
| LOWER('FUNCTION') |
+-------------------+
| function          |
+-------------------+

mysql&gt; SELECT UPPER('function');
+-------------------+
| UPPER('function') |
+-------------------+
| FUNCTION          |
+-------------------+</pre>
<div>
<p><b>REPEAT (str,count):</b> This function is used to repeat string by given count.</p>
<pre class="crayon-plain-tag">mysql&gt; SELECT REPEAT(' String Function',3);
+-----------------------------------------------------+
| REPEAT(' String Function',3)                        |
+-----------------------------------------------------+
|  String Function String Function String Function    |
+-----------------------------------------------------+</pre>
<p><b>REPLACE(str,from_str,to_str):</b> This function is used to replace a substring by the new string. You can replace any part of string by giving from_string and to_string.</p>
<pre class="crayon-plain-tag">mysql&gt; SELECT REPLACE('String Function','Function','Demo');
+----------------------------------------------+
| REPLACE('String Function','Function','Demo') |
+----------------------------------------------+
| String Demo                                  |
+----------------------------------------------+</pre>
</p></div>
<div></div>
<p><b>REVERSE(str) :</b> This function is used to reverse each word of string.</p>
<pre class="crayon-plain-tag">mysql&gt; SELECT REVERSE ('String Function');
+-----------------------------+
| REVERSE ('String Function') |
+-----------------------------+
| noitcnuF gnirtS             |
+-----------------------------+</pre> </p>
<p><b>STRCMP(str1,str2):</b> This function is used to compare two string. This is not case sensitive. If both strings match, then it returns 0 else it returns 1 or -1 base on how first string is bigger than the second string.</p>
<pre class="crayon-plain-tag">mysql&gt; SELECT STRCMP('String','String');
+---------------------------+
| STRCMP('String','String') |
+---------------------------+
|                         0 |
+---------------------------+

mysql&gt; SELECT STRCMP('STRING','string');
+---------------------------+
| STRCMP('STRING','string') |
+---------------------------+
|                         0 |
+---------------------------+

mysql&gt; SELECT STRCMP('STRING','Function');
+-----------------------------+
| STRCMP('STRING','Function') |
+-----------------------------+
|                           1 |
+-----------------------------+

mysql&gt; SELECT STRCMP('String', 'tring');
+---------------------------+
| STRCMP('String', 'tring') |
+---------------------------+
|                        -1 |
+---------------------------+</pre> </p>
<p><b>SUBSTRING (str,pos) :</b> This function is used to return sub part of string by giving position.</p>
<pre class="crayon-plain-tag">mysql&gt; SELECT SUBSTRING('String Function',5);
+--------------------------------+
| SUBSTRING('String Function',5) |
+--------------------------------+
| ng Function                    |
+--------------------------------+</pre> </p>
<p><b>SUBSTRING (str,pos,len):</b> This function is used to return sub part of string by giving position and length of return string.</p>
<pre class="crayon-plain-tag">mysql&gt; SELECT SUBSTRING('String Function',5,8);
+----------------------------------+
| SUBSTRING('String Function',5,8) |
+----------------------------------+
| ng Funct                         |
+----------------------------------+</pre> </p>
<p><b>TRIM (str):</b> This function is used to remove all prefixes or suffixes from string. You can also use LTRIM(str) and RTRIM(str) to remove space from the left or right only.</p>
<pre class="crayon-plain-tag">mysql&gt; SELECT TRIM(' Test ');
+----------------+
| TRIM(' Test ') |
+----------------+
| Test           |
+----------------+</pre> </p>
<p>Above all are basic and important String manipulation function in MySQL.</p>
<div></div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2015/05/mysql-string-functions/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
