If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Not using an incrementing ID

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-02-10, 11:00
Eiolon Eiolon is offline
Registered User
 
Join Date: Jan 2006
Posts: 26
Not using an incrementing ID

I am working on an ordering system, and for the orders table, I didn't want the order ID to start with 1 and auto increment as they are placed. Instead I was going to randomly generate an ID for each order placed, such as: 3029491.

Would there be an inherient problems to doing such a thing? Is it unwise to do it? Should I still have the ID auto increment and just have another column be an random ID column? Either way, it will always be unique.

Thanks!
Reply With Quote
  #2 (permalink)  
Old 12-02-10, 11:12
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Quote:
Originally Posted by Eiolon View Post
Would there be an inherient problems to doing such a thing?
other than that you have to have code in case the random number generates an existing number (so just generate another one), no
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 12-02-10, 11:47
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
Until SQL 6.5, random distribution was actively encouraged (this is part of what made GUID values popular). Before you "burn daylight" on finding a mangable solution, I'd suggest that you at least investigate using GUIDs instead of recreating them.

-PatP
__________________
In theory, theory and practice are identical. In practice, theory and practice are unrelated.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On