<?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>natural key &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/natural-key/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>Wed, 22 Feb 2017 21:35:50 +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: Database Developer (T-SQL) Interview Questions and Answers (Day-2)</title>
		<link>https://www.dbrnd.com/2016/06/sql-server-database-developer-t-sql-interview-questions-and-answers-primary-unique-foregin-super-natural-surrogate-candidate-composite-key-normalization-day-2/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Mon, 13 Jun 2016 19:27:38 +0000</pubDate>
				<category><![CDATA[SQL Server Interview]]></category>
		<category><![CDATA[answers]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[composite key]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[Database Developer]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[discard query result]]></category>
		<category><![CDATA[foreign key]]></category>
		<category><![CDATA[Interviews]]></category>
		<category><![CDATA[natural key]]></category>
		<category><![CDATA[Primary key]]></category>
		<category><![CDATA[questions]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></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[T-SQL]]></category>
		<category><![CDATA[TSQL]]></category>
		<category><![CDATA[unique key]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3035</guid>

					<description><![CDATA[What are the different main type of normalization? In database design, we start with one single table, with all possible columns. A lot of redundant data would be present since it’s a single table. The process of removing the redundant data, by splitting up the table in a well defined fashion is called normalization. First [&#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%2F2016%2F06%2Fsql-server-database-developer-t-sql-interview-questions-and-answers-primary-unique-foregin-super-natural-surrogate-candidate-composite-key-normalization-day-2%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-2%29" 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%2F06%2Fsql-server-database-developer-t-sql-interview-questions-and-answers-primary-unique-foregin-super-natural-surrogate-candidate-composite-key-normalization-day-2%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-2%29" 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%2F06%2Fsql-server-database-developer-t-sql-interview-questions-and-answers-primary-unique-foregin-super-natural-surrogate-candidate-composite-key-normalization-day-2%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-2%29" 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%2F06%2Fsql-server-database-developer-t-sql-interview-questions-and-answers-primary-unique-foregin-super-natural-surrogate-candidate-composite-key-normalization-day-2%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-2%29" 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%2F06%2Fsql-server-database-developer-t-sql-interview-questions-and-answers-primary-unique-foregin-super-natural-surrogate-candidate-composite-key-normalization-day-2%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-2%29" 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%2F06%2Fsql-server-database-developer-t-sql-interview-questions-and-answers-primary-unique-foregin-super-natural-surrogate-candidate-composite-key-normalization-day-2%2F&amp;linkname=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-2%29" 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%2F06%2Fsql-server-database-developer-t-sql-interview-questions-and-answers-primary-unique-foregin-super-natural-surrogate-candidate-composite-key-normalization-day-2%2F&#038;title=SQL%20Server%3A%20Database%20Developer%20%28T-SQL%29%20Interview%20Questions%20and%20Answers%20%28Day-2%29" data-a2a-url="https://www.dbrnd.com/2016/06/sql-server-database-developer-t-sql-interview-questions-and-answers-primary-unique-foregin-super-natural-surrogate-candidate-composite-key-normalization-day-2/" data-a2a-title="SQL Server: Database Developer (T-SQL) Interview Questions and Answers (Day-2)"></a></p><p><strong>What are the different main type of normalization?</strong></p>
<blockquote><p>In database design, we start with one single table, with all possible columns. A lot of redundant data would be present since it’s a single table. The process of removing the redundant data, by splitting up the table in a well defined fashion is called normalization.</p>
<p><strong>First Normal Form (1NF):</strong>A relation is said to be in first normal form if and only if all underlying domains contain atomic values only. After 1NF, we can still have redundant data.</p>
<p><strong>Second Normal Form (2NF):</strong>A relation is said to be in 2NF if and only if it is in 1NF and every non key attribute is fully dependent on the primary key. After 2NF, we can still have redundant data.</p>
<p><strong>Third Normal Form (3NF):</strong>A relation is said to be in 3NF, if and only if it is in 2NF and every non key attribute is non-transitively dependent on the primary key.</p></blockquote>
<p><strong>What is the Primary key?</strong></p>
<blockquote><p>A primary key is a one or more fields that uniquely identifies a row in a table. The primary key cannot be null (blank). The primary key is indexed.</p>
<p>A primary key is a value that can be used to identify a unique row in a table.</p></blockquote>
<p><strong>What should be your best practice with Primary Key?</strong></p>
<blockquote class="wp-embedded-content" data-secret="9NktFhZ1G1"><p><a href="https://www.dbrnd.com/2015/09/best-practice-for-primary-key-in-database-management-system/">Best practice for Primary Key in Database Management System</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/09/best-practice-for-primary-key-in-database-management-system/embed/#?secret=9NktFhZ1G1" data-secret="9NktFhZ1G1" width="600" height="338" title="&#8220;Best practice for Primary Key in Database Management System&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>How to find all the Tables without having a Primary Key?</strong></p>
<blockquote class="wp-embedded-content" data-secret="9xi49k8KqF"><p><a href="https://www.dbrnd.com/2016/01/sql-server-script-to-find-all-the-tables-without-having-a-primary-key/">SQL Server: Script to find all the Tables without having a Primary Key</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/01/sql-server-script-to-find-all-the-tables-without-having-a-primary-key/embed/#?secret=9xi49k8KqF" data-secret="9xi49k8KqF" width="600" height="338" title="&#8220;SQL Server: Script to find all the Tables without having a Primary Key&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>What is the Unique key?</strong></p>
<blockquote><p>Unique key also ensures data uniqueness like primary key.</p>
<p>A column with unique key defined allows null value. By default, it creates non-clustered index.</p></blockquote>
<p><strong>What is the Super key?</strong></p>
<blockquote><p>A superkey is defined in the relational model as a set of attributes of a relation variable (relvar) for which it holds that in all relations assigned to that variable there are no two distinct tuples (rows) that have the same values for the attributes in this set. Equivalently a superkey can also be defined as a set of attributes of a relvar upon which all attributes of the relvar are functionally dependent.</p></blockquote>
<p><strong>What is the Foreign key?</strong></p>
<blockquote><p> A foreign key is a relationship between columns in two database tables (one of which is indexed) designed to insure consistency of data.</p>
<p>Usually a foreign key in one table refers to the primary key (PK) of another table. This way references can be made to link information together and it is an essential part of database normalization.</p></blockquote>
<p><strong>How to Find Foreign key References in SQL Server?</strong></p>
<blockquote class="wp-embedded-content" data-secret="JBYQPgMqrd"><p><a href="https://www.dbrnd.com/2015/06/find-foreign-key-reference-source-target-in-sql-server/">How to Find Foreign key References in SQL Server</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/06/find-foreign-key-reference-source-target-in-sql-server/embed/#?secret=JBYQPgMqrd" data-secret="JBYQPgMqrd" width="600" height="338" title="&#8220;How to Find Foreign key References in SQL Server&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>How you can find source and destination information of all foreign keys?</strong></p>
<blockquote class="wp-embedded-content" data-secret="aR1cKvqKP8"><p><a href="https://www.dbrnd.com/2015/10/postgresql-script-to-find-source-and-destination-of-all-foreign-key-constraint/">PostgreSQL: Script to find Source and Destination of All Foreign Key Constraint</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/10/postgresql-script-to-find-source-and-destination-of-all-foreign-key-constraint/embed/#?secret=aR1cKvqKP8" data-secret="aR1cKvqKP8" width="600" height="338" title="&#8220;PostgreSQL: Script to find Source and Destination of All Foreign Key Constraint&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>What is the Composite key?</strong></p>
<blockquote><p>A composite key consists of more than one field to uniquely identify a record. This differs from a compound key in that one or more of the attributes, which make up the key, are not simple keys in their own right. Taking the example from compound key, imagine we identified a student by their firstName + lastName.</p>
<p>In our table representing students on modules our primary key would now be firstName + lastName + moduleCode. Because firstName + lastName represent a unique reference to a student, they are not each simple keys, they have to be combined in order to uniquely identify the student. Therefore the key for this table is a composite key.</p></blockquote>
<p><strong>What is the Natural key?</strong></p>
<blockquote><p>A composite primary key which is composed of attributes (fields) which already exist in the real world e.g. First Name, Last Name, Social Security Number.</p></blockquote>
<p><strong>What is the Surrogate key?</strong></p>
<blockquote><p>A primary key which is internally generated (typically auto-incremental integer value) that does not exist in the real world i.e. ID=1 for Customer A and ID=2 for Customer B serves to uniquely identify the record but has no bearing the customer themselves and is an attribute they will never (need to) be aware of.</p></blockquote>
<p><strong>What is the Candidate key?</strong></p>
<blockquote><p>A candidate key is a column or group of columns that can uniquely identify a row in the table without referring to any other source.</p></blockquote>
<p><strong>What is the Compound key?</strong></p>
<blockquote><p> A composite key consisting of two or more fields that uniquely describe a row in a table. The difference between compound and candidate is that all of the fields in the compound key are foreign keys; in the candidate key one or more of the fields may be foreign keys.</p></blockquote>
<p><strong>Can a foreign key reference a non-primary key?</strong></p>
<blockquote><p>Yes, a foreign key can actually reference a key that is not the primary key of a table. But, a foreign key must reference a unique key.</p></blockquote>
<p><strong>Can a foreign key contain null values?</strong></p>
<blockquote><p>Yes, a foreign key can hold NULL values. Because foreign keys can reference unique, non-primary keys – which can hold NULL values – this means that foreign keys can themselves hold NULL values as well.</p></blockquote>
<p><strong>What are the type of data integrity?</strong></p>
<ul>
<li>Domain Integrity: data type, check constraints</li>
<li>Entity Integrity: primary key, unique constraint</li>
<li>Referential Integrity: foreign key constraint</li>
</ul>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Best practice for Primary Key in Database Management System</title>
		<link>https://www.dbrnd.com/2015/09/best-practice-for-primary-key-in-database-management-system/</link>
					<comments>https://www.dbrnd.com/2015/09/best-practice-for-primary-key-in-database-management-system/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Thu, 17 Sep 2015 20:02:47 +0000</pubDate>
				<category><![CDATA[Database Designing]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database concept]]></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[natural key]]></category>
		<category><![CDATA[Primary key]]></category>
		<category><![CDATA[RDBMS]]></category>
		<category><![CDATA[surrogate key]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=653</guid>

					<description><![CDATA[Hello Guys, The discussion on Primary Key is very common and even not require so much attention because each and every database professionals have excellent knowledge on the Database Primary Key. I agree that you all are using Primary Key in your database system, but still, I want to write theory about: what should 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%2F09%2Fbest-practice-for-primary-key-in-database-management-system%2F&amp;linkname=Best%20practice%20for%20Primary%20Key%20in%20Database%20Management%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%2Fbest-practice-for-primary-key-in-database-management-system%2F&amp;linkname=Best%20practice%20for%20Primary%20Key%20in%20Database%20Management%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%2Fbest-practice-for-primary-key-in-database-management-system%2F&amp;linkname=Best%20practice%20for%20Primary%20Key%20in%20Database%20Management%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%2Fbest-practice-for-primary-key-in-database-management-system%2F&amp;linkname=Best%20practice%20for%20Primary%20Key%20in%20Database%20Management%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%2Fbest-practice-for-primary-key-in-database-management-system%2F&amp;linkname=Best%20practice%20for%20Primary%20Key%20in%20Database%20Management%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%2Fbest-practice-for-primary-key-in-database-management-system%2F&amp;linkname=Best%20practice%20for%20Primary%20Key%20in%20Database%20Management%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%2Fbest-practice-for-primary-key-in-database-management-system%2F&#038;title=Best%20practice%20for%20Primary%20Key%20in%20Database%20Management%20System" data-a2a-url="https://www.dbrnd.com/2015/09/best-practice-for-primary-key-in-database-management-system/" data-a2a-title="Best practice for Primary Key in Database Management System"></a></p><p>Hello Guys,<br />
<em>The discussion on Primary Key is very common and even not require so much attention because each and every database professionals have excellent knowledge on the Database Primary Key.</em></p>
<p><em>I agree that you all are using Primary Key in your database system, but still, I want to write theory about: what should be your best practice with Primary Key.</em></p>
<p><em>This is a very familiar concept, but then also sometimes database professionals are making a mistake, and even they don&#8217;t know about it.</em></p>
<p>Let me start this theory,</p>
<p><strong>First, I would like to define the Primary Key.</strong></p>
<blockquote><p>A Primary key is a unique identifier for each record, but this is the only half story. Another main purpose is to relate records for different tables and playing the leading role as a pointer.</p></blockquote>
<p><strong>The best data type for Primary Key.</strong></p>
<blockquote><p>I suggest choosing a numeric data type because storage of numeric type is very compact than any character data type and even most of the primary key is a foreign key for another table, so smaller key performs faster than the other.</p></blockquote>
<p><strong>Are you updating your primary key?</strong></p>
<blockquote><p>Primary key should never change or update. The updating primary key might create more problem because it used by multiple indexes and used as a foreign key.</p></blockquote>
<p><strong>Are you using Natural Key as a Primary Key?</strong></p>
<blockquote><p><a href="https://en.wikipedia.org/wiki/Natural_key" target="_blank">What is Natural Key?</a><br />
A natural key is a key that formed of attributes that already exist in the real world. For example, a US citizen&#8217;s social security number could be used as a natural key.</p></blockquote>
<blockquote><p>I suggest to avoid natural key because of one main reason which is human error. The Application or Human has to enter SSN (social security number) into a database, and there might be chance for the wrong insertion, and maybe your system cannot detect this error at the same time, but once you find this error then you will face more problems for changing the data of the primary key.</p></blockquote>
<blockquote><p>You can use this, but you should make sure about the correct data and also using of Natural Key can prevent some additional joins.</p></blockquote>
<p><strong>Are you using Surrogate Key as a Primary Key?</strong></p>
<blockquote><p><a href="https://en.wikipedia.org/wiki/Surrogate_key" target="_blank">What is Surrogate Key?</a><br />
A surrogate key in a database is a unique identifier for either an entity in the modelled world or an object in the database. The surrogate key is not derived from application data, unlike a natural key which is derived from application data.</p></blockquote>
<blockquote><p>I suggest to use Surrogate Key as Primary Key which is generated by database management system and not derived from any application data. In the background, Your primary key handled by database program and application user.</p></blockquote>
<p><strong>Are you creating a Primary Key for each and every table?</strong></p>
<blockquote><p>If you are doing this, then you are doing right. But, If you are not doing this then your database may have many <a href="https://www.dbrnd.com/2015/08/what-is-heap-table/" target="_blank">HEAP tables</a> which are not good because primary key also works as cluster index and also responsible for the correct order of the data.<br />
Your best practice is to create an auto_increment column for each and every table.</p></blockquote>
<p><strong>Now, a task is for you, please check your database primary key and judge yourself. </strong><br />
<strong>In above theory whatever I have written is my viewpoint and concern, but you might have a different view so take decision base on your system requirement.</strong></p>
<p><strong>For further suggestions, your comments are most welcome.</strong></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2015/09/best-practice-for-primary-key-in-database-management-system/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
