Solved

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

Posted on 2013-02-07
2
224 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 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

710 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