473,396 Members | 1,936 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Multiple Identity Columns

I am new to SQL and I am making an asp.net page in which is a small airline service for a project for scool. For one of my tables I have:

AccountID, CustomerName, FrequentFlierMiles, FrequentFliernum for my column names. The acount AccountID column can not have duplicated values and FrequentFliernum can not have duplicated values and the only thing I could think from stopping that is through identity specification, the problem is you can only set one of the columns to have identity specification.

The AccountID and FrequentFliernum I would like to automatically increment by 1.


Anyhelp is appreciated. If this does not make sense I will try re-writing it.
Feb 18 '08 #1
2 2980
ck9663
2,878 Expert 2GB
I am new to SQL and I am making an asp.net page in which is a small airline service for a project for scool. For one of my tables I have:

AccountID, CustomerName, FrequentFlierMiles, FrequentFliernum for my column names. The acount AccountID column can not have duplicated values and FrequentFliernum can not have duplicated values and the only thing I could think from stopping that is through identity specification, the problem is you can only set one of the columns to have identity specification.

The AccountID and FrequentFliernum I would like to automatically increment by 1.


Anyhelp is appreciated. If this does not make sense I will try re-writing it.
Let's see if I got this right. You want two unique columns, in this case AccountID and FrequentFliernum. I did not know you can not have two identity columns in one table, or at least I have not tried it.

Since the nature of the columns you're trying to use should be unique within the table, but it does not mean they could not be the same (AccountId = FrequentFliernum). Now, since it would also make sense to make them different (FrequentFliernum could have more digits), you can have the first few digit as the AccountId.

So you can have AccountId using an IDENTITY column. You can actually use a AccountId + A random number for your FrequentFliernum. Since AccountId is an IDENTITY which makes it unique, then your entire FrequentFliernum is unique. You just want it longer (more digits). In the business world, these numbers have some conventions. First few digits could be the AccountId followed by (maybe) Branch ID, followed by (another maybe) type of account like Platinum, Gold, etc...

Another thing, IDENTITY columns ensures uniqueness, not sequence. Meaning if you have an IDENTITY column on table, and you delete a row, that number will not be reused.

If you really have to do it the way you describe it, try using a
1. Calculated/Computed Column
2. Trigger to implement your formua

Just some thought...

Good luck...

-- CK
Feb 18 '08 #2
Thank You, I appreciate your help.
Feb 18 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: newtophp2000 | last post by:
I have been using the following query to identify the IDENTITY columns in a given table. (The query is inside an application.) select column_name from information_schema.columns where...
17
by: Trevor Best | last post by:
I don't know if this has been reported before but it appears to be a bug with Access. If I create two tables both with an identity column then create an insert trigger on table1 that inserts a...
3
by: Henrik Dahl | last post by:
Hello! From default, the ASPNET user is giving the process identity for the ASP.NET runtime environment of IIS, however it's possible to change the user by modifying the <processModel> element...
2
by: Omavlana Omav | last post by:
Hi, I have created a datatable, dataadapter, added the table to a dataset and filling the table. Here I want to add an identity column to the above datatable and Later I will use this...
2
by: Diego | last post by:
Hi everybody! I'm using DB2 PE v8.2.3 for linux. I've defined a database with the following schema: ANNOTATION(ID,AUTHOR,TEXT) ANNOTATION_BOOK(ANNOTATION_ID,OBJECT_ID)...
41
by: pb648174 | last post by:
In a multi-user environment, I would like to get a list of Ids generated, similar to: declare @LastId int select @LastId = Max(Id) From TableMania INSERT INTO TableMania (ColumnA, ColumnB)...
2
by: alee | last post by:
I am writing a stored procedure to handle Order and OrderDetail tables. I created a tempTable physically on the database, and insert the OrderDetails into the tempTable first, then I try to use the...
1
by: Magnus | last post by:
I'm testing walkthrough saving data to a Database (Multiple Tables). http://msdn2.microsoft.com/en-us/library/4esb49b4(VS.80).aspx In the famous Customer/Order example, I'm getting referential...
11
by: stegze | last post by:
Hi All, I have a problem with a DB2 server of my customer. It is a Debian Linux running DB2 Express-C. I have an IDENTITY field as PK in a table and I use this value as FK in another table. Two...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.