472,378 Members | 1,443 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Will "Random AutoNumber" reuse deleted values?

yf
A KB article
"http://support.microsoft.com/default.aspx?scid=kb;en-us;209599" tells
that the maximum number of records that a table may hold if the PRIMARY
key data type is set to AUTONUMBER is 4,294,967,295.

Suppose the PRIMARY key data type is set to "RANDOM" AutoNumber.

Suppose an application
(a) successfully INSERTS "X" records, then
(b) successfully DELETES "Y" records (X >= Y), then
(c) successfully INSERTS "Z" records to a table to the capacity limit
of that primary key (i.e. insertion of a "Z+1"th record would have
caused a "duplicate primary key" condition).

Suppose there are no hardware or software failures and unlimited
HDD/RAM space.

Is it guaranteed that (X-Y+Z) = 4,294,967,295 ?
I.e. will Random AutoNumber reuse all "holes" left after deletion of Y
records?

--

Nov 13 '05 #1
4 5016
It's random: there's no guarantee that an attempt won't be made to reuse any
number.

Since there's a 2 GB limit on an MDB, I rather suspect you'll hit that limit
long before you use up all of the autonumber values.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"yf" <yf******@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
A KB article
"http://support.microsoft.com/default.aspx?scid=kb;en-us;209599" tells
that the maximum number of records that a table may hold if the PRIMARY
key data type is set to AUTONUMBER is 4,294,967,295.

Suppose the PRIMARY key data type is set to "RANDOM" AutoNumber.

Suppose an application
(a) successfully INSERTS "X" records, then
(b) successfully DELETES "Y" records (X >= Y), then
(c) successfully INSERTS "Z" records to a table to the capacity limit
of that primary key (i.e. insertion of a "Z+1"th record would have
caused a "duplicate primary key" condition).

Suppose there are no hardware or software failures and unlimited
HDD/RAM space.

Is it guaranteed that (X-Y+Z) = 4,294,967,295 ?
I.e. will Random AutoNumber reuse all "holes" left after deletion of Y
records?

--

Nov 13 '05 #2
yf
Too bad... the other scenario I had in mind was:
{add 10,000,000 records, delete 9,000,000 records} repeated daily.
Looks like after 429 days I'll exsaust all 4,294,967,295 Random
AutoNumber unique values and will start occasionally (with a
probability 10%) getting a "duplicate primary key"?

Nov 13 '05 #3
yf wrote:
Too bad... the other scenario I had in mind was:
{add 10,000,000 records, delete 9,000,000 records} repeated daily.
Looks like after 429 days I'll exsaust all 4,294,967,295 Random
AutoNumber unique values and will start occasionally (with a
probability 10%) getting a "duplicate primary key"?


It would need compactinmg every day then :-)

BTW for adding 1,000,000 records a day, are you sure you want to use
something as lightweight as Access/Jet?

--
This sig left intentionally blank
Nov 13 '05 #4
Once a record is deleted, its Autonumber value can be reused. Even with a
standard incremental Autonumber, a value can be reused if the highest-numbered
value is deleted, then the database is compacted. For this reason, no kind of
Autonumber is suitable for use as a logical key.

If, however, the Autonumber value will only be used as a surrogate key within
the database app and will never be used as an external refrence, and if the
database makes good use of enforced referential integrity rules, there should
be no consequences to possible reuse of previously deleted Autonumber values.

So - you may frequently want to use Autonumer keys as surrogate keys, but use
another technique other than autonumber to generate unique logical keys. A
good logical key might be a string representation of a new GUID obtained using
a Windows API call. Another option I rather like for building unique logical
keys is CCur(Format(Now,"yyyymmdd") & Format(Timer*10,"000000.00") &
Format(Rnd*100,"00")), making sure to call Randomize at some point prior to
executing this code. If, for some reason, you'd like make sure records will
sort randomly using the logical key, change that formula to
CCur(Format(Rnd*100,"00") & Format(Timer*1000,"00000000") &
Format(Now,"ddmm.yyyy")).

If you need more assurance that the random number part won't be duplicated
during the same millisecond, you can replace the call to Rnd with a call to a
custom non-repeating hash procedure and seed its initial counter with a random
value using Rnd. An easy hash (though not very random if that matters) is to
count from 1 and XOR the counter value with the random seed. To be fancier,
you could use modulus multiplication or exponentiation, though that can be
tricky in VB/VBA.

On 6 Dec 2004 13:16:43 -0800, "yf" <yf******@gmail.com> wrote:
A KB article
"http://support.microsoft.com/default.aspx?scid=kb;en-us;209599" tells
that the maximum number of records that a table may hold if the PRIMARY
key data type is set to AUTONUMBER is 4,294,967,295.

Suppose the PRIMARY key data type is set to "RANDOM" AutoNumber.

Suppose an application
(a) successfully INSERTS "X" records, then
(b) successfully DELETES "Y" records (X >= Y), then
(c) successfully INSERTS "Z" records to a table to the capacity limit
of that primary key (i.e. insertion of a "Z+1"th record would have
caused a "duplicate primary key" condition).

Suppose there are no hardware or software failures and unlimited
HDD/RAM space.

Is it guaranteed that (X-Y+Z) = 4,294,967,295 ?
I.e. will Random AutoNumber reuse all "holes" left after deletion of Y
records?


Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: bhennon | last post by:
Hey all, I have a small php script that calls a random image at the following page. http://www.2006ymcanationals.com/random.php IT WORKS IF I go directly to the above link. I am trying to...
4
by: Jesse Noller | last post by:
Hello - I'm probably missing something here, but I have a problem where I am populating a list of lists like this: list1 = list2 = list3 = main_list =
6
by: Tom | last post by:
Is there a way to not display "Autonumber" in the primary key testbox when the PK is an autonumber in a new record? Tom
1
by: BT Openworld | last post by:
I've just had to upgrade to Access 2003. Our company's main sales database started in Access V1.0 and has progressed through V2.0 and 97 without problems. I've converted it to 2003 format and have...
2
by: plawrow | last post by:
Hi, I am trying to assign "autonumber" for each line related to given record. TRANSACTION# DATE AMOUNT 3 01/01/05 100 3 01/01/05 150 3 ...
21
by: MLH | last post by:
I have an A97 database table (tblCorrespondence] in a database installed at 2 sites. The table's key field is not a natural key - its an autonumber field. Here are the values at the 2 sites....
11
by: Alan Mailer | last post by:
A project I'm working on is going to use VB6 as a front end. The back end is going to be pre-existing MS Access 2002 database tables which already have records in them *but do not have any...
9
by: Tom_F | last post by:
To comp.databases.ms-access -- I just discovered, to my more than mild dismay, that some tables in my Microsoft Access 2003 database have duplicate numbers in the "AutoNumber" field. (Field...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

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.