<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; Difference Between Candidate Keys and Primary Key</title>
	<atom:link href="http://blog.sqlauthority.com/2009/10/22/sql-server-difference-between-candidate-keys-and-primary-key-2/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2009/10/22/sql-server-difference-between-candidate-keys-and-primary-key-2/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Fri, 10 Feb 2012 02:12:04 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: sherkhan</title>
		<link>http://blog.sqlauthority.com/2009/10/22/sql-server-difference-between-candidate-keys-and-primary-key-2/#comment-244099</link>
		<dc:creator><![CDATA[sherkhan]]></dc:creator>
		<pubDate>Thu, 26 Jan 2012 15:44:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7111#comment-244099</guid>
		<description><![CDATA[Very nice explanation]]></description>
		<content:encoded><![CDATA[<p>Very nice explanation</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Meer Afghan</title>
		<link>http://blog.sqlauthority.com/2009/10/22/sql-server-difference-between-candidate-keys-and-primary-key-2/#comment-243265</link>
		<dc:creator><![CDATA[Meer Afghan]]></dc:creator>
		<pubDate>Wed, 25 Jan 2012 04:54:47 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7111#comment-243265</guid>
		<description><![CDATA[Thanks alot today i understand difference b/w these keys.]]></description>
		<content:encoded><![CDATA[<p>Thanks alot today i understand difference b/w these keys.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: muthu</title>
		<link>http://blog.sqlauthority.com/2009/10/22/sql-server-difference-between-candidate-keys-and-primary-key-2/#comment-206613</link>
		<dc:creator><![CDATA[muthu]]></dc:creator>
		<pubDate>Mon, 28 Nov 2011 18:04:53 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7111#comment-206613</guid>
		<description><![CDATA[hi sir
i have created some tables using primary key and foreign key .when i was deleting records for that table which id can i taken . either primary key or foreign key id . which one is best one ? please tell me with soome examples]]></description>
		<content:encoded><![CDATA[<p>hi sir<br />
i have created some tables using primary key and foreign key .when i was deleting records for that table which id can i taken . either primary key or foreign key id . which one is best one ? please tell me with soome examples</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tubss</title>
		<link>http://blog.sqlauthority.com/2009/10/22/sql-server-difference-between-candidate-keys-and-primary-key-2/#comment-170049</link>
		<dc:creator><![CDATA[tubss]]></dc:creator>
		<pubDate>Tue, 20 Sep 2011 19:25:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7111#comment-170049</guid>
		<description><![CDATA[Thanks a lot  I understand difference  key&#039;s !]]></description>
		<content:encoded><![CDATA[<p>Thanks a lot  I understand difference  key&#8217;s !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alok</title>
		<link>http://blog.sqlauthority.com/2009/10/22/sql-server-difference-between-candidate-keys-and-primary-key-2/#comment-164751</link>
		<dc:creator><![CDATA[Alok]]></dc:creator>
		<pubDate>Fri, 02 Sep 2011 11:11:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7111#comment-164751</guid>
		<description><![CDATA[Thanks alot today i understand difference b/w these keys.]]></description>
		<content:encoded><![CDATA[<p>Thanks alot today i understand difference b/w these keys.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Murtaza</title>
		<link>http://blog.sqlauthority.com/2009/10/22/sql-server-difference-between-candidate-keys-and-primary-key-2/#comment-158625</link>
		<dc:creator><![CDATA[Murtaza]]></dc:creator>
		<pubDate>Thu, 18 Aug 2011 01:45:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7111#comment-158625</guid>
		<description><![CDATA[Thanks a lot Pinal Dave..]]></description>
		<content:encoded><![CDATA[<p>Thanks a lot Pinal Dave..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sunit mishra</title>
		<link>http://blog.sqlauthority.com/2009/10/22/sql-server-difference-between-candidate-keys-and-primary-key-2/#comment-155367</link>
		<dc:creator><![CDATA[sunit mishra]]></dc:creator>
		<pubDate>Tue, 09 Aug 2011 10:29:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7111#comment-155367</guid>
		<description><![CDATA[don&#039;t be complex try to be simple for u and for others...........]]></description>
		<content:encoded><![CDATA[<p>don&#8217;t be complex try to be simple for u and for others&#8230;&#8230;&#8230;..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Javed Khan</title>
		<link>http://blog.sqlauthority.com/2009/10/22/sql-server-difference-between-candidate-keys-and-primary-key-2/#comment-136793</link>
		<dc:creator><![CDATA[Javed Khan]]></dc:creator>
		<pubDate>Thu, 26 May 2011 11:13:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7111#comment-136793</guid>
		<description><![CDATA[Very nice articles
Thanks a lots]]></description>
		<content:encoded><![CDATA[<p>Very nice articles<br />
Thanks a lots</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Carlton</title>
		<link>http://blog.sqlauthority.com/2009/10/22/sql-server-difference-between-candidate-keys-and-primary-key-2/#comment-94382</link>
		<dc:creator><![CDATA[John Carlton]]></dc:creator>
		<pubDate>Wed, 20 Oct 2010 06:42:37 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7111#comment-94382</guid>
		<description><![CDATA[Possibly, selecting the proper key will make a best work! I like your post about key and primary keys. It’s being applied essentially and suitably.]]></description>
		<content:encoded><![CDATA[<p>Possibly, selecting the proper key will make a best work! I like your post about key and primary keys. It’s being applied essentially and suitably.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: NandaKumar</title>
		<link>http://blog.sqlauthority.com/2009/10/22/sql-server-difference-between-candidate-keys-and-primary-key-2/#comment-92994</link>
		<dc:creator><![CDATA[NandaKumar]]></dc:creator>
		<pubDate>Thu, 14 Oct 2010 07:33:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7111#comment-92994</guid>
		<description><![CDATA[Hi Umesh,

Try STUFF string function...

REgards,
NandaKumar]]></description>
		<content:encoded><![CDATA[<p>Hi Umesh,</p>
<p>Try STUFF string function&#8230;</p>
<p>REgards,<br />
NandaKumar</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Umesh</title>
		<link>http://blog.sqlauthority.com/2009/10/22/sql-server-difference-between-candidate-keys-and-primary-key-2/#comment-86883</link>
		<dc:creator><![CDATA[Umesh]]></dc:creator>
		<pubDate>Tue, 07 Sep 2010 09:42:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7111#comment-86883</guid>
		<description><![CDATA[Hi 
i am regular reader of your blog i am currently working as BI 
and found one query form my client they want a employee id 
start from  &#039;00001&#039; and increment by 1 like 00001,00002,.......00011 and so on. i tried to generate a employee id with above pattern.  but still have no luck please help me out of this problem 

Umesh]]></description>
		<content:encoded><![CDATA[<p>Hi<br />
i am regular reader of your blog i am currently working as BI<br />
and found one query form my client they want a employee id<br />
start from  &#8217;00001&#8242; and increment by 1 like 00001,00002,&#8230;&#8230;.00011 and so on. i tried to generate a employee id with above pattern.  but still have no luck please help me out of this problem </p>
<p>Umesh</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anil</title>
		<link>http://blog.sqlauthority.com/2009/10/22/sql-server-difference-between-candidate-keys-and-primary-key-2/#comment-81044</link>
		<dc:creator><![CDATA[Anil]]></dc:creator>
		<pubDate>Wed, 21 Jul 2010 04:58:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7111#comment-81044</guid>
		<description><![CDATA[@ Marko ,

As it is being said &quot;Besides, this Primary Key may not be used in Joins.&quot;

It is quite possible that other tables having foreign key referring the primarykey(let it be non Identity column which you have created separately and declared it as pk)

So PK mostly be used as foreign key which can appear in joins also as well as in where clause to filter the records. 

so whats the point to create separate column as pk and not to use identity columns as pk?


-Anil]]></description>
		<content:encoded><![CDATA[<p>@ Marko ,</p>
<p>As it is being said &#8220;Besides, this Primary Key may not be used in Joins.&#8221;</p>
<p>It is quite possible that other tables having foreign key referring the primarykey(let it be non Identity column which you have created separately and declared it as pk)</p>
<p>So PK mostly be used as foreign key which can appear in joins also as well as in where clause to filter the records. </p>
<p>so whats the point to create separate column as pk and not to use identity columns as pk?</p>
<p>-Anil</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marko Parkkola</title>
		<link>http://blog.sqlauthority.com/2009/10/22/sql-server-difference-between-candidate-keys-and-primary-key-2/#comment-63403</link>
		<dc:creator><![CDATA[Marko Parkkola]]></dc:creator>
		<pubDate>Sun, 21 Mar 2010 18:58:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7111#comment-63403</guid>
		<description><![CDATA[I think it depends but I must say I&#039;m not 100% sure about this.

If both indexes, clustered and non-clustered are ordered in the same way then there&#039;s probably no benefit from non-clustered index.

But I&#039;ve heard that in some cases having two indexes ordered in opposite ways will increase performance for select queries.

Also if I use multiple fields in the join/where then I&#039;ll add composite indexes to the table that may overlap with existing ones.

But anyway, always measure your performance after you&#039;ve done changes. For instance, I did some changes to a DB last week and I&#039;m planning to spend part of next week to observe how those changes are affecting the whole software, not just that table.]]></description>
		<content:encoded><![CDATA[<p>I think it depends but I must say I&#8217;m not 100% sure about this.</p>
<p>If both indexes, clustered and non-clustered are ordered in the same way then there&#8217;s probably no benefit from non-clustered index.</p>
<p>But I&#8217;ve heard that in some cases having two indexes ordered in opposite ways will increase performance for select queries.</p>
<p>Also if I use multiple fields in the join/where then I&#8217;ll add composite indexes to the table that may overlap with existing ones.</p>
<p>But anyway, always measure your performance after you&#8217;ve done changes. For instance, I did some changes to a DB last week and I&#8217;m planning to spend part of next week to observe how those changes are affecting the whole software, not just that table.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Devesh</title>
		<link>http://blog.sqlauthority.com/2009/10/22/sql-server-difference-between-candidate-keys-and-primary-key-2/#comment-63395</link>
		<dc:creator><![CDATA[Devesh]]></dc:creator>
		<pubDate>Sun, 21 Mar 2010 14:00:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7111#comment-63395</guid>
		<description><![CDATA[@ Marko,

I don&#039;t think it is a great idea to create a clustered as well as nonclustered indexes on the same column. as the clustered index will be having a reference to all the columns in the table but the nonclustered index will only have a reference to the columns specified.

The key point here is that whenever You update or delete a row (or column) 

all the index will be updated.
It is redundant to have two indexes on a column.

In Your case the indexes will take nearly twice time to update, so more time on locks on table.  

So a big performance hit.]]></description>
		<content:encoded><![CDATA[<p>@ Marko,</p>
<p>I don&#8217;t think it is a great idea to create a clustered as well as nonclustered indexes on the same column. as the clustered index will be having a reference to all the columns in the table but the nonclustered index will only have a reference to the columns specified.</p>
<p>The key point here is that whenever You update or delete a row (or column) </p>
<p>all the index will be updated.<br />
It is redundant to have two indexes on a column.</p>
<p>In Your case the indexes will take nearly twice time to update, so more time on locks on table.  </p>
<p>So a big performance hit.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marko Parkkola</title>
		<link>http://blog.sqlauthority.com/2009/10/22/sql-server-difference-between-candidate-keys-and-primary-key-2/#comment-61787</link>
		<dc:creator><![CDATA[Marko Parkkola]]></dc:creator>
		<pubDate>Thu, 25 Feb 2010 19:36:41 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7111#comment-61787</guid>
		<description><![CDATA[Hi,

I have to gracefully disagree and exactly for the points you make against using IDENTITY as PK.

&gt; There is no use of this Primary Key in both application and in T-SQL

That is exactly why I always prefer adding &quot;separate&quot; IDENTITY column as PK. I don&#039;t want to ever show PK values outside the DB. If I need to expose PK outside I make sure in the application code that it is only seen in the data acces layer.

&gt; Besides, this Primary Key may not be used in Joins.

But does it matter? You can use other column in joins and build unique index to those. You just have to make sure you don&#039;t kill performance with additional indexes, of course. If I use PK column in joins or in where-clause, I usually add non-clustered index to it also.]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I have to gracefully disagree and exactly for the points you make against using IDENTITY as PK.</p>
<p>&gt; There is no use of this Primary Key in both application and in T-SQL</p>
<p>That is exactly why I always prefer adding &#8220;separate&#8221; IDENTITY column as PK. I don&#8217;t want to ever show PK values outside the DB. If I need to expose PK outside I make sure in the application code that it is only seen in the data acces layer.</p>
<p>&gt; Besides, this Primary Key may not be used in Joins.</p>
<p>But does it matter? You can use other column in joins and build unique index to those. You just have to make sure you don&#8217;t kill performance with additional indexes, of course. If I use PK column in joins or in where-clause, I usually add non-clustered index to it also.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: santosh kumar patro</title>
		<link>http://blog.sqlauthority.com/2009/10/22/sql-server-difference-between-candidate-keys-and-primary-key-2/#comment-61772</link>
		<dc:creator><![CDATA[santosh kumar patro]]></dc:creator>
		<pubDate>Thu, 25 Feb 2010 14:56:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7111#comment-61772</guid>
		<description><![CDATA[Hi,

I am not able to get the concept regarding the following point that you have specified:

Please note that many database experts suggest that it is not a good practice to make Identity Column as Primary Key. The reason behind this suggestion is that many times Identity Column that has been assigned as Primary Key does not play any role in database. There is no use of this Primary Key in both application and in T-SQL. Besides, this Primary Key may not be used in Joins. It is a known fact that when there is JOIN on Primary Key or when Primary Key is used in the WHERE condition it usually gives better performance than non primary key columns. This argument is absolutely valid and one must make sure not to use such Identity Column.

Please explain it more clearly regarding the above point.

Thanks,
Santosh]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I am not able to get the concept regarding the following point that you have specified:</p>
<p>Please note that many database experts suggest that it is not a good practice to make Identity Column as Primary Key. The reason behind this suggestion is that many times Identity Column that has been assigned as Primary Key does not play any role in database. There is no use of this Primary Key in both application and in T-SQL. Besides, this Primary Key may not be used in Joins. It is a known fact that when there is JOIN on Primary Key or when Primary Key is used in the WHERE condition it usually gives better performance than non primary key columns. This argument is absolutely valid and one must make sure not to use such Identity Column.</p>
<p>Please explain it more clearly regarding the above point.</p>
<p>Thanks,<br />
Santosh</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: CALM</title>
		<link>http://blog.sqlauthority.com/2009/10/22/sql-server-difference-between-candidate-keys-and-primary-key-2/#comment-57623</link>
		<dc:creator><![CDATA[CALM]]></dc:creator>
		<pubDate>Sun, 15 Nov 2009 16:04:47 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7111#comment-57623</guid>
		<description><![CDATA[Thank you, good enough]]></description>
		<content:encoded><![CDATA[<p>Thank you, good enough</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mahesh Nair</title>
		<link>http://blog.sqlauthority.com/2009/10/22/sql-server-difference-between-candidate-keys-and-primary-key-2/#comment-57476</link>
		<dc:creator><![CDATA[Mahesh Nair]]></dc:creator>
		<pubDate>Tue, 10 Nov 2009 08:09:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7111#comment-57476</guid>
		<description><![CDATA[We are using for our table a dedicated column as primary key, with data type NUMERIC(15, 10). The decimal part used for uniquely identify the record the increment by 0.0000000001 and numeric part to identify the Various Client / Support DB.
Is it a good practice to follow such logic. Which data type shall be ideal for Primary key.]]></description>
		<content:encoded><![CDATA[<p>We are using for our table a dedicated column as primary key, with data type NUMERIC(15, 10). The decimal part used for uniquely identify the record the increment by 0.0000000001 and numeric part to identify the Various Client / Support DB.<br />
Is it a good practice to follow such logic. Which data type shall be ideal for Primary key.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shantanu Gupta</title>
		<link>http://blog.sqlauthority.com/2009/10/22/sql-server-difference-between-candidate-keys-and-primary-key-2/#comment-57240</link>
		<dc:creator><![CDATA[Shantanu Gupta]]></dc:creator>
		<pubDate>Sun, 01 Nov 2009 05:21:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7111#comment-57240</guid>
		<description><![CDATA[Very good explanations above.

I have one more query relating primary key with performance.

How will performance get affected if I change-

1. Primary key column to some other column which is a candidate key.

2. Content of a primary key. i.e. changing only 1 value in primary key column.]]></description>
		<content:encoded><![CDATA[<p>Very good explanations above.</p>
<p>I have one more query relating primary key with performance.</p>
<p>How will performance get affected if I change-</p>
<p>1. Primary key column to some other column which is a candidate key.</p>
<p>2. Content of a primary key. i.e. changing only 1 value in primary key column.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vaibhav</title>
		<link>http://blog.sqlauthority.com/2009/10/22/sql-server-difference-between-candidate-keys-and-primary-key-2/#comment-57239</link>
		<dc:creator><![CDATA[Vaibhav]]></dc:creator>
		<pubDate>Sun, 01 Nov 2009 04:40:37 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7111#comment-57239</guid>
		<description><![CDATA[Thanks Steve, for the explanation.]]></description>
		<content:encoded><![CDATA[<p>Thanks Steve, for the explanation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pinaldave</title>
		<link>http://blog.sqlauthority.com/2009/10/22/sql-server-difference-between-candidate-keys-and-primary-key-2/#comment-57188</link>
		<dc:creator><![CDATA[pinaldave]]></dc:creator>
		<pubDate>Fri, 30 Oct 2009 18:29:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7111#comment-57188</guid>
		<description><![CDATA[Steve G.

Very good input. Thanks for your note.

Kind Regards,
Pinal]]></description>
		<content:encoded><![CDATA[<p>Steve G.</p>
<p>Very good input. Thanks for your note.</p>
<p>Kind Regards,<br />
Pinal</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve G.</title>
		<link>http://blog.sqlauthority.com/2009/10/22/sql-server-difference-between-candidate-keys-and-primary-key-2/#comment-57185</link>
		<dc:creator><![CDATA[Steve G.]]></dc:creator>
		<pubDate>Fri, 30 Oct 2009 17:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7111#comment-57185</guid>
		<description><![CDATA[@Vaibhav
&gt;&gt; why it is not a good practice to make Identity Column as Primary Key.

Actually, it can be a good practice. There are plenty of DBA&#039;s who would say &quot;NEVER!!&quot; and others who say &quot;ALWAYS!&quot; to identify columns as the primary key. Reality is that if you have a situation where the values in the primary key can change or if you have a table with sequentially increasing records, then an identity can make an excellent primary key. 

Two examples come to mind: First any time you&#039;re dealing with people, the values that might make up the primary key are always mutable. Names not only are not unique but can change, state-issued identity numbers (Social Security in the US or ID cards elsewhere) can change or simply be entered wrong. In this case a separate unique identifier is a good thing.

Second example is a history table. While a timestamp is the first, natural, option for a primary key, it may not be unique depending on the rate at which records are entered. In this case, an identity column as a primary key could be the right answer.

Basically, the real answer is that the right primary key depends on your data and your usage, not on a rule that is simply applied without thinking.

Steve G.]]></description>
		<content:encoded><![CDATA[<p>@Vaibhav<br />
&gt;&gt; why it is not a good practice to make Identity Column as Primary Key.</p>
<p>Actually, it can be a good practice. There are plenty of DBA&#8217;s who would say &#8220;NEVER!!&#8221; and others who say &#8220;ALWAYS!&#8221; to identify columns as the primary key. Reality is that if you have a situation where the values in the primary key can change or if you have a table with sequentially increasing records, then an identity can make an excellent primary key. </p>
<p>Two examples come to mind: First any time you&#8217;re dealing with people, the values that might make up the primary key are always mutable. Names not only are not unique but can change, state-issued identity numbers (Social Security in the US or ID cards elsewhere) can change or simply be entered wrong. In this case a separate unique identifier is a good thing.</p>
<p>Second example is a history table. While a timestamp is the first, natural, option for a primary key, it may not be unique depending on the rate at which records are entered. In this case, an identity column as a primary key could be the right answer.</p>
<p>Basically, the real answer is that the right primary key depends on your data and your usage, not on a rule that is simply applied without thinking.</p>
<p>Steve G.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vaibhav</title>
		<link>http://blog.sqlauthority.com/2009/10/22/sql-server-difference-between-candidate-keys-and-primary-key-2/#comment-57119</link>
		<dc:creator><![CDATA[Vaibhav]]></dc:creator>
		<pubDate>Wed, 28 Oct 2009 20:42:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7111#comment-57119</guid>
		<description><![CDATA[Very nice explanation. But I do not get one thing, why it is not a good practice to make Identity Column as Primary Key.]]></description>
		<content:encoded><![CDATA[<p>Very nice explanation. But I do not get one thing, why it is not a good practice to make Identity Column as Primary Key.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave F.</title>
		<link>http://blog.sqlauthority.com/2009/10/22/sql-server-difference-between-candidate-keys-and-primary-key-2/#comment-57041</link>
		<dc:creator><![CDATA[Dave F.]]></dc:creator>
		<pubDate>Mon, 26 Oct 2009 17:35:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7111#comment-57041</guid>
		<description><![CDATA[@Garry, if you need multiple records for the PK, then the solution is to create a new table and join as needed. That&#039;s the relational solution to the problem you are describing. 

If the app requirements change so drastically that one needs to change the PK, then change the structure of the db. Might as well make a wholesale change at that time, but until then, benefit from the use of logical keys useful for the problem domain instead of creating artificial, synthetic columns as PK.]]></description>
		<content:encoded><![CDATA[<p>@Garry, if you need multiple records for the PK, then the solution is to create a new table and join as needed. That&#8217;s the relational solution to the problem you are describing. </p>
<p>If the app requirements change so drastically that one needs to change the PK, then change the structure of the db. Might as well make a wholesale change at that time, but until then, benefit from the use of logical keys useful for the problem domain instead of creating artificial, synthetic columns as PK.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Garry</title>
		<link>http://blog.sqlauthority.com/2009/10/22/sql-server-difference-between-candidate-keys-and-primary-key-2/#comment-57039</link>
		<dc:creator><![CDATA[Garry]]></dc:creator>
		<pubDate>Mon, 26 Oct 2009 15:11:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7111#comment-57039</guid>
		<description><![CDATA[As mentioned, you can indeed concatenate multiple columns as a primary key.  I generally discourage this behavior with my projects mainly because you then have to carry all columns through to other tables when using that concatenated key as a Foreign Key, and also usually end up having to tolerate changes to one or more of those concatenated columns.

Most often, I have seen concatenated keys used as a lazy way to enforce uniqueness amongst certain columns.  In those situations, I usually demand that a unique key be set up (such as an Identity), and then create Unique Constraints on the columns that need to be unique (a unique constraint in SQL Server can be multi-column).

As to updating keys, I really again try to discourage using any field that may need to be updated as a primary key.  You end up having all kinds of relational issues if you have the need to update a key value that has enforced relationships with other tables.  You also never know if the business requirements will change, with the result that what used to be a unique primary key now must have multiple records in the table with that value (Product Name or SKU for example).  By breaking the key out to a value that is unique and generally unrelated to the item itself in the first place, you can avoid later issues when the requirements of the app change.  :)]]></description>
		<content:encoded><![CDATA[<p>As mentioned, you can indeed concatenate multiple columns as a primary key.  I generally discourage this behavior with my projects mainly because you then have to carry all columns through to other tables when using that concatenated key as a Foreign Key, and also usually end up having to tolerate changes to one or more of those concatenated columns.</p>
<p>Most often, I have seen concatenated keys used as a lazy way to enforce uniqueness amongst certain columns.  In those situations, I usually demand that a unique key be set up (such as an Identity), and then create Unique Constraints on the columns that need to be unique (a unique constraint in SQL Server can be multi-column).</p>
<p>As to updating keys, I really again try to discourage using any field that may need to be updated as a primary key.  You end up having all kinds of relational issues if you have the need to update a key value that has enforced relationships with other tables.  You also never know if the business requirements will change, with the result that what used to be a unique primary key now must have multiple records in the table with that value (Product Name or SKU for example).  By breaking the key out to a value that is unique and generally unrelated to the item itself in the first place, you can avoid later issues when the requirements of the app change.  :)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

