Solved

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

Posted on 2013-02-07
2
226 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 66

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 66

Expert Comment

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

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

621 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