Solved

Are you supposed to apply the primary key to an IDENTITY column? Please elaborate.

Posted on 2013-02-07
2
220 Views
Last Modified: 2013-02-07
When creating  an IDENTITY column in  a table do you also apply a primary key to it?


Example:
CREATE TABLE HR.Employees(
EmployeeId INT IDENTITY(1000 ,2) NOT NULL
,etc…)
0
Comment
Question by:rhservan
  • 2
2 Comments
 
LVL 65

Accepted Solution

by:
Jim Horn earned 500 total points
ID: 38865555
Identity fields are almost always primary keys yes, as it guarantees uniqueness in a row, but it is not required.

In your above T-SQL, making EmployeID the identity field might not always work, if the client sees a scenario where they would want to manually change the id for whatever reason.   If that's the case, an identity field would be the primary key, the actual EmployeeID would be what's called a 'business key'.  Forms would always display business key, and the database is related via the identity field.

You'll have to feel them out on that one.
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 38865687
Thanks for the grade.  Good luck with your project.  -Jim
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now