<?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>Database Design &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/database-design/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, 05 Feb 2018 19:18:00 +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>SQL Server: Avoid the use of Indexes on VARCHAR columns</title>
		<link>https://www.dbrnd.com/2017/01/sql-server-avoid-the-use-of-indexes-on-varchar-columns-clustered-non-clustered-index-size/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Thu, 12 Jan 2017 21:08:07 +0000</pubDate>
				<category><![CDATA[Database Designing]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[clustered index]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[Database Design]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[Index key size]]></category>
		<category><![CDATA[non clustered index]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tunning]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=4301</guid>

					<description><![CDATA[I am also adding a Database Design category for this post, because what I am feeling that you guys must know about this before designing tables or indexes. You can create Indexes on VARCHAR columns, but you should not create indexes on big size of VARCHAR Columns. Indexes also require storing data as key for [&#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%2F2017%2F01%2Fsql-server-avoid-the-use-of-indexes-on-varchar-columns-clustered-non-clustered-index-size%2F&amp;linkname=SQL%20Server%3A%20Avoid%20the%20use%20of%20Indexes%20on%20VARCHAR%20columns" 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%2F2017%2F01%2Fsql-server-avoid-the-use-of-indexes-on-varchar-columns-clustered-non-clustered-index-size%2F&amp;linkname=SQL%20Server%3A%20Avoid%20the%20use%20of%20Indexes%20on%20VARCHAR%20columns" 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%2F2017%2F01%2Fsql-server-avoid-the-use-of-indexes-on-varchar-columns-clustered-non-clustered-index-size%2F&amp;linkname=SQL%20Server%3A%20Avoid%20the%20use%20of%20Indexes%20on%20VARCHAR%20columns" 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%2F2017%2F01%2Fsql-server-avoid-the-use-of-indexes-on-varchar-columns-clustered-non-clustered-index-size%2F&amp;linkname=SQL%20Server%3A%20Avoid%20the%20use%20of%20Indexes%20on%20VARCHAR%20columns" 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%2F2017%2F01%2Fsql-server-avoid-the-use-of-indexes-on-varchar-columns-clustered-non-clustered-index-size%2F&amp;linkname=SQL%20Server%3A%20Avoid%20the%20use%20of%20Indexes%20on%20VARCHAR%20columns" 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%2F2017%2F01%2Fsql-server-avoid-the-use-of-indexes-on-varchar-columns-clustered-non-clustered-index-size%2F&amp;linkname=SQL%20Server%3A%20Avoid%20the%20use%20of%20Indexes%20on%20VARCHAR%20columns" 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%2F2017%2F01%2Fsql-server-avoid-the-use-of-indexes-on-varchar-columns-clustered-non-clustered-index-size%2F&#038;title=SQL%20Server%3A%20Avoid%20the%20use%20of%20Indexes%20on%20VARCHAR%20columns" data-a2a-url="https://www.dbrnd.com/2017/01/sql-server-avoid-the-use-of-indexes-on-varchar-columns-clustered-non-clustered-index-size/" data-a2a-title="SQL Server: Avoid the use of Indexes on VARCHAR columns"></a></p><p>I am also adding a Database Design category for this post, because what I am feeling that you guys must know about this before designing tables or indexes. </p>
<p>You can create Indexes on VARCHAR columns, but you should not create indexes on big size of VARCHAR Columns. </p>
<p>Indexes also require storing data as key for accessing associated records. There is a size limitation of index key values. </p>
<blockquote><p>Before SQL Server 2016, Index key size limitation was 900 bytes for Clustered and Non-Clustered index column.<br />
SQL Server 2016 increased this limitation for Non-Clustered Index and now it is up to 1700 bytes, but for Clustered Index column it is still 900 bytes.</p></blockquote>
<p>Let me demonstrate this.</p>
<p><strong>Create a sample table with Nonclustered Index:</strong></p>
<pre class="crayon-plain-tag">CREATE TABLE tbl_TestVarcharNonClustered
(
	ID INT
	,Name VARCHAR(2000)
)
GO

CREATE NONCLUSTERED INDEX idx_tbl_TestVarcharNonClustered_Name ON tbl_TestVarcharNonClustered(Name)
GO</pre> </p>
<p><strong>You will get a below warning:</strong><br />
Because we have set Name VARCHAR(2000).</p>
<pre class="crayon-plain-tag">Warning! The maximum key length for a nonclustered index is 1700 bytes. The index 'idx_tbl_TestVarcharNonClustered_Name' has maximum length of 2000 bytes. For some combination of large values, the insert/update operation will fail.</pre> </p>
<p><strong>Try to insert 1701 bytes data:</strong></p>
<pre class="crayon-plain-tag">INSERT INTO tbl_TestVarcharNonClustered 
VALUES (1,REPLICATE('a',1701))
GO</pre> </p>
<p><strong>You will get a below error:</strong></p>
<pre class="crayon-plain-tag">Msg 1946, Level 16, State 3, Line 1
Operation failed. The index entry of length 1701 bytes for the index 'idx_tbl_TestVarcharNonClustered_Name' exceeds the maximum length of 1700 bytes for nonclustered indexes.</pre> </p>
<p><strong>You can successfully run below INSERT, because it inserts only 1700 bytes:</strong></p>
<pre class="crayon-plain-tag">INSERT INTO tbl_TestVarcharNonClustered 
VALUES (1,REPLICATE('a',1700))
GO</pre> </p>
<p><strong>Now, create a sample table with Clustered Index:</strong></p>
<pre class="crayon-plain-tag">CREATE TABLE tbl_TestVarcharClustered
(
	ID INT
	,Name VARCHAR(2000)
)
GO

CREATE CLUSTERED INDEX idx_tbl_TestVarcharClustered_Name ON tbl_TestVarcharClustered(Name)
GO</pre> </p>
<p><strong>You will get a below warning:</strong><br />
Because we have set Name VARCHAR(2000) on cluster index column.</p>
<pre class="crayon-plain-tag">Warning! The maximum key length for a clustered index is 900 bytes. The index 'idx_tbl_TestVarcharClustered_Name' has maximum length of 2000 bytes. For some combination of large values, the insert/update operation will fail.</pre> </p>
<p><strong>Try to insert a over size data like more than 900 bytes:</strong></p>
<pre class="crayon-plain-tag">INSERT INTO tbl_TestVarcharClustered 
VALUES (1,REPLICATE('a',1001))
GO</pre> </p>
<p><strong>You will get a below error:</strong></p>
<pre class="crayon-plain-tag">Msg 1946, Level 16, State 3, Line 1
Operation failed. The index entry of length 1001 bytes for the index 'idx_tbl_TestVarcharClustered_Name' exceeds the maximum length of 900 bytes for clustered indexes.</pre> </p>
<p><strong>You can successfully run below INSERT, because it inserts only 900 bytes:</strong></p>
<pre class="crayon-plain-tag">INSERT INTO tbl_TestVarcharClustered 
VALUES (1,REPLICATE('a',900))
GO</pre> </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Database Design: Common Practices for Database Developers and Application Developers</title>
		<link>https://www.dbrnd.com/2016/12/database-design-common-practices-for-database-developers-and-application-developers/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 26 Dec 2016 17:37:29 +0000</pubDate>
				<category><![CDATA[Database Designing]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[Application Developer]]></category>
		<category><![CDATA[Cluster Index]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database concept]]></category>
		<category><![CDATA[Database Design]]></category>
		<category><![CDATA[Database Developer]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[database standards]]></category>
		<category><![CDATA[Database Theory]]></category>
		<category><![CDATA[database topic]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[Performance Optimization]]></category>
		<category><![CDATA[RDBMS]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=4117</guid>

					<description><![CDATA[<div><img width="448" height="318" src="https://www.dbrnd.com/wp-content/uploads/2016/12/DatabaseDesignBestPractices.jpg" class="attachment-post-image size-post-image wp-post-image" alt="Database Design Best Practices" decoding="async" fetchpriority="high" srcset="https://www.dbrnd.com/wp-content/uploads/2016/12/DatabaseDesignBestPractices.jpg 448w, https://www.dbrnd.com/wp-content/uploads/2016/12/DatabaseDesignBestPractices-300x213.jpg 300w, https://www.dbrnd.com/wp-content/uploads/2016/12/DatabaseDesignBestPractices-150x106.jpg 150w" sizes="(max-width: 448px) 100vw, 448px" /></div>In this post, I am sharing the list of common practices for Database Designing which should follow by Database Developers and Application Developers. Foreign keys should have indexes on them, and it should often cover multiple columns base on the queries you need to execute. You should make sure about the referential integrity by enforcing [&#8230;]]]></description>
										<content:encoded><![CDATA[<div><img width="448" height="318" src="https://www.dbrnd.com/wp-content/uploads/2016/12/DatabaseDesignBestPractices.jpg" class="attachment-post-image size-post-image wp-post-image" alt="Database Design Best Practices" decoding="async" srcset="https://www.dbrnd.com/wp-content/uploads/2016/12/DatabaseDesignBestPractices.jpg 448w, https://www.dbrnd.com/wp-content/uploads/2016/12/DatabaseDesignBestPractices-300x213.jpg 300w, https://www.dbrnd.com/wp-content/uploads/2016/12/DatabaseDesignBestPractices-150x106.jpg 150w" sizes="(max-width: 448px) 100vw, 448px" /></div><p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F12%2Fdatabase-design-common-practices-for-database-developers-and-application-developers%2F&amp;linkname=Database%20Design%3A%20Common%20Practices%20for%20Database%20Developers%20and%20Application%20Developers" 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%2F2016%2F12%2Fdatabase-design-common-practices-for-database-developers-and-application-developers%2F&amp;linkname=Database%20Design%3A%20Common%20Practices%20for%20Database%20Developers%20and%20Application%20Developers" 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%2F2016%2F12%2Fdatabase-design-common-practices-for-database-developers-and-application-developers%2F&amp;linkname=Database%20Design%3A%20Common%20Practices%20for%20Database%20Developers%20and%20Application%20Developers" 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%2F2016%2F12%2Fdatabase-design-common-practices-for-database-developers-and-application-developers%2F&amp;linkname=Database%20Design%3A%20Common%20Practices%20for%20Database%20Developers%20and%20Application%20Developers" 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%2F2016%2F12%2Fdatabase-design-common-practices-for-database-developers-and-application-developers%2F&amp;linkname=Database%20Design%3A%20Common%20Practices%20for%20Database%20Developers%20and%20Application%20Developers" 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%2F2016%2F12%2Fdatabase-design-common-practices-for-database-developers-and-application-developers%2F&amp;linkname=Database%20Design%3A%20Common%20Practices%20for%20Database%20Developers%20and%20Application%20Developers" 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%2F2016%2F12%2Fdatabase-design-common-practices-for-database-developers-and-application-developers%2F&#038;title=Database%20Design%3A%20Common%20Practices%20for%20Database%20Developers%20and%20Application%20Developers" data-a2a-url="https://www.dbrnd.com/2016/12/database-design-common-practices-for-database-developers-and-application-developers/" data-a2a-title="Database Design: Common Practices for Database Developers and Application Developers"></a></p><p>In this post, I am sharing the list of common practices for Database Designing which should follow by Database Developers and Application Developers.</p>
<ul>
<li>Foreign keys should have indexes on them, and it should often cover multiple columns base on the queries you need to execute.</li>
<li>You should make sure about the referential integrity by enforcing the Foreign Keys.<br />
Choose right column for CLUSTER Index.</li>
<li>You should apply proper indexes and do not create duplicate indexes and avoid creation of unnecessary indexes.</li>
<li>You should not put auto-number data type as a PRIMARY KEY to join a FOREIGN KEY in a parent/child table relationship.</li>
<li>If your system is running large number of INSERT/DELETE, you should avoid frequent update of database Statistics.</li>
<li>You should choose the write data-type for your data columns.</li>
<li>Please separate big size of columns from main table and store in a different table.</li>
<li>You should apply proper column name.</li>
<li>Use proper data types for Latitude, Longitude, IP-Address, Network Address, Mac Address.</li>
<li>Use Natural Primary key rather than Surrogate Primary key. Natural Primary keys are keys base on an external meaningful data. Surrogate Primary key are keys base on an auto-increment number or values which have no meaning outside the system.</li>
<li>You must use Stored Procedures or Stored Functions.</li>
<li>Please avoid too much database normalization and try to design your database to achieve Database Normalization + Database Denormalization. You should design this combination to achieve the performance.</li>
<li>Avoid inappropriate or excessive use of cursors.</li>
<li>Avoid inappropriate use of Database Transactions (BEGIN&#8230;COMMIT).</li>
<li>Try to avoid the use of OR condition because an AND condition restricts the data set, whereas an OR condition grows it.</li>
<li>You should do detailed performance analysis on queries.</li>
<li>Try to use the Prepared SQL Statement which caches the compiled query and the execution plan for better performance. It will also better protect you against SQL injection attacks.</li>
<li>Please do not simplify your complex queries through the views.</li>
<li>Please do not use DISTINCT frequently. Many developers are using DISTINCT to hide duplicate data, but you should stop and remove the duplicate data.</li>
<li>Try to avoid Correlated Subqueries.</li>
<li>Do not store comma delimited list in a table.</li>
<li>Do not store JSON data in TEXT COLUMN, you should use JSON data type for it.</li>
<li>Please do not use comma separated table names in SELECT query, use explicit JOINs conditions to avoid internal Cartesian products.</li>
</ul>
<p>&nbsp;<br />
<strong>The list is not final yet, you guys can add/share a comment and make it final&#8230;</strong></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>The truth about to store images into the Database System or into the File System</title>
		<link>https://www.dbrnd.com/2015/09/store-image-into-database-system-or-file-system/</link>
					<comments>https://www.dbrnd.com/2015/09/store-image-into-database-system-or-file-system/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sat, 05 Sep 2015 19:40:01 +0000</pubDate>
				<category><![CDATA[Database Designing]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[blob]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database concept]]></category>
		<category><![CDATA[Database Design]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[database standards]]></category>
		<category><![CDATA[Database Theory]]></category>
		<category><![CDATA[database topic]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[FileStream]]></category>
		<category><![CDATA[Image]]></category>
		<category><![CDATA[RDBMS]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=589</guid>

					<description><![CDATA[As a Database Architecture, this is my responsibility to write and share my knowledge on which one is best option to store images either into the Database System or into the File System? I found this is most asking questions by Database Professional. Let me discuss the all truth about these both option so Database [&#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%2F09%2Fstore-image-into-database-system-or-file-system%2F&amp;linkname=The%20truth%20about%20to%20store%20images%20into%20the%20Database%20System%20or%20into%20the%20File%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%2F09%2Fstore-image-into-database-system-or-file-system%2F&amp;linkname=The%20truth%20about%20to%20store%20images%20into%20the%20Database%20System%20or%20into%20the%20File%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%2F09%2Fstore-image-into-database-system-or-file-system%2F&amp;linkname=The%20truth%20about%20to%20store%20images%20into%20the%20Database%20System%20or%20into%20the%20File%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%2F09%2Fstore-image-into-database-system-or-file-system%2F&amp;linkname=The%20truth%20about%20to%20store%20images%20into%20the%20Database%20System%20or%20into%20the%20File%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%2F09%2Fstore-image-into-database-system-or-file-system%2F&amp;linkname=The%20truth%20about%20to%20store%20images%20into%20the%20Database%20System%20or%20into%20the%20File%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%2F09%2Fstore-image-into-database-system-or-file-system%2F&amp;linkname=The%20truth%20about%20to%20store%20images%20into%20the%20Database%20System%20or%20into%20the%20File%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%2F09%2Fstore-image-into-database-system-or-file-system%2F&#038;title=The%20truth%20about%20to%20store%20images%20into%20the%20Database%20System%20or%20into%20the%20File%20System" data-a2a-url="https://www.dbrnd.com/2015/09/store-image-into-database-system-or-file-system/" data-a2a-title="The truth about to store images into the Database System or into the File System"></a></p><p>As a Database Architecture, this is my responsibility to write and share my knowledge on which one is best option to store images either into the Database System or into the File System?</p>
<p>I found this is most asking questions by Database Professional.<br />
Let me discuss the all truth about these both option so Database Professional can take the right decision.</p>
<h2><strong>&#8221; The truth about to store images into the File System &#8220;</strong></h2>
<blockquote><p>Store image into the File System and store the only path of that image into the Database System.</p></blockquote>
<blockquote><p>You can serve this images or pictures as static files across the network.</p></blockquote>
<blockquote><p>The Operating System can easily cache the image data for better access performance.</p></blockquote>
<blockquote><p>The management of files in the File System is very important, You have to manage proper folder structure, different schedule for taking the backup of all files.</p></blockquote>
<blockquote><p>If you are planning to migrate your application from one server to another at that time you also have to take the backup of not only image files, but you have to also maintain the same folder structure and path structure.</p></blockquote>
<blockquote><p>This is not advisable to store more than 3000 files into one folder, after some number of limit you should create a new folder for further files and this is advisable for performance aspect. </p></blockquote>
<blockquote><p>You can write an automated program to create the new folder structure.</p></blockquote>
<blockquote><p>The thumb rule of RDBMS is data integrity, If you are storing images in the file system, the image data disconnects with a database system.</p></blockquote>
<blockquote><p>You should also take care about a security of file directory, if someone deletes your image files, your application should throw an error like &#8220;Image is not found&#8221;.</p></blockquote>
<h2><strong>&#8221; The truth about to store images into the Database System &#8220;</strong></h2>
<blockquote><p>You can create a separate table or column for <strong>BLOB</strong> data type in which you can store images.</p></blockquote>
<blockquote><p>You can manage proper data integrity within the database system.</p></blockquote>
<blockquote><p>You need only one system to manage and perform any action like migration, replication.</p></blockquote>
<blockquote><p>You can take a full database backup with included all the image data, but this will take more time depends on the size of image data.</p></blockquote>
<blockquote><p>You can also commit image data like any other data.</p></blockquote>
<blockquote><p>The storing images into database system are very resource consuming.</p></blockquote>
<blockquote><p>Imagine, If you stored millions of images in the database and each size is around 60 KB, you have to use your SELECT statement properly otherwise this will create performance issues. You cannot put SELECT * in such a condition.</p></blockquote>
<blockquote><p>The image data is more secure in the database system because you can easily manage different privileges for users.</p></blockquote>
<blockquote><p>You can also create a dedicated server, database, schema for image data just like any other file server system.</p></blockquote>
<blockquote><p>If you are using SQL Server 2008, one new <strong>FileStream</strong> data type gives a very good optimized approach for storing files in a database system.</p></blockquote>
<h2><strong>&#8221; Conclusion&#8230; &#8220;</strong></h2>
<blockquote><p>You should take decision basis on your system complexity and scalability. I would suggest you go with File System. The Database Storage is not advisable, but still, people are using it.
</p></blockquote>
<p>Above are my views and concerns, but you should take a decision base on all the above facts.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2015/09/store-image-into-database-system-or-file-system/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>Best way to store IP Address into Database System</title>
		<link>https://www.dbrnd.com/2015/05/store-ip-address-into-database-system/</link>
					<comments>https://www.dbrnd.com/2015/05/store-ip-address-into-database-system/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sun, 31 May 2015 16:58:37 +0000</pubDate>
				<category><![CDATA[Database Designing]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database concept]]></category>
		<category><![CDATA[Database Design]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[database standards]]></category>
		<category><![CDATA[Database Theory]]></category>
		<category><![CDATA[database topic]]></category>
		<category><![CDATA[ip address]]></category>
		<category><![CDATA[RDBMS]]></category>
		<category><![CDATA[Storage]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=218</guid>

					<description><![CDATA[In this post, I am sharing about the effective storage of IP-Address into Database System. Now let&#8217;s talk about four part of IP-Address. E.g, 152.145.10.25 Many database developers or database designer store this IP-Address into one column which is VARCHAR(15). What do you think? Is this effective storage of IP-Address?. Now imagine that you are [&#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%2Fstore-ip-address-into-database-system%2F&amp;linkname=Best%20way%20to%20store%20IP%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%2Fstore-ip-address-into-database-system%2F&amp;linkname=Best%20way%20to%20store%20IP%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%2Fstore-ip-address-into-database-system%2F&amp;linkname=Best%20way%20to%20store%20IP%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%2Fstore-ip-address-into-database-system%2F&amp;linkname=Best%20way%20to%20store%20IP%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%2Fstore-ip-address-into-database-system%2F&amp;linkname=Best%20way%20to%20store%20IP%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%2Fstore-ip-address-into-database-system%2F&amp;linkname=Best%20way%20to%20store%20IP%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%2Fstore-ip-address-into-database-system%2F&#038;title=Best%20way%20to%20store%20IP%20Address%20into%20Database%20System" data-a2a-url="https://www.dbrnd.com/2015/05/store-ip-address-into-database-system/" data-a2a-title="Best way to store IP Address into Database System"></a></p><p>In this post, I am sharing about the effective storage of IP-Address into Database System.</p>
<p>Now let&#8217;s talk about four part of IP-Address.</p>
<p>E.g, 152.145.10.25</p>
<p>Many database developers or database designer store this IP-Address into one column which is VARCHAR(15).</p>
<p><strong>What do you think? Is this effective storage of IP-Address?.</strong></p>
<blockquote><p>Now imagine that you are playing with 10,0,00,00 online customers in which all this IP-Address of the customer requires for analysis.</p>
<p>If we stored all IP-Addresses into one column, you have to perform string manipulation for finding a particular range of IP-Address.<br />
The string operation is always costly and not advisable.</p></blockquote>
<p><b><br />
Effective storage of IP-Address is very simple:</b></p>
<p>Just divide your full-length IP-Address into four part.</p>
<p>E.g.</p>
<p>Full IP-Address: 152.145.10.25</p>
<p>Four Part :</p>
<p>152</p>
<p>145</p>
<p>10</p>
<p>25</p>
<p>Now create four tinyint/smallint column to store this four different part.</p>
<p>column like,</p>
<p>ip1 tinyint</p>
<p>ip2 tinyint</p>
<p>ip3 tinyint</p>
<p>ip4 tinyint</p>
<p>The full IP-Address split into four different integer part.</p>
<p>Now the task is very easy:<br />
You can also apply an index on all this part and perform range analysis very quickly.</p>
<blockquote><p><b>Yes, I agree that during insertion you also require splitting for storing in the different columns, but this is only a one time process after that you can easily use different parts for various analysis. </b></p></blockquote>
<p>During select, you can also concat this four part and make full IP-Address for display purpose.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2015/05/store-ip-address-into-database-system/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<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 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 loading="lazy" 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="auto, (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 loading="lazy" 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>
	</channel>
</rss>
