Problem with DBMS (how to have a unique column)

Login to reply to this topic.
Tue, 2006-03-28 20:47
Joined: 2005-07-10
Forum posts: 68
Hello,

I need a database in my app which will hold several data such as string, date, etc and inserting and deleting date takes place frequently. I have to identify each field uniquely. Note that I can have same data in several rows. For instance,

1. abcd
2. efgh
3. ijkl
4. abcd
5. abcd

if “abcd” is selected, I have to know exactly from which field it came. So I thought it will be good idea to keep one extra column that will have unique value. I tried as follows:

TDbCol keyCol(_L("Column_4"), EDbColUint32);
keyCol.iAttributes = TDbCol::EAutoIncrement;

This is incrementing value like 0,1,2,3,4,5,6,7Â….. But the problem is that when I delete a date, it does not short the value and keeps on incrementing from the height value. For example I delete row containing 1,2,3,4 and add two new data. My key column will have value like 0,5,6,7,8,9. So it is incrementing and in some day it will reach to the maximum value that TUint32 can hold (4294967295). So there must be some other way to meet such criteria? So could any of you suggest me how to solve this? Note that comparing data wonÂ’t help at all as long as I would have similar data in several rows.

Wed, 2006-03-29 08:01
Joined: 2005-02-11
Forum posts: 214
Re: Problem with DBMS (how to have a unique column)
That's how all databases work. But this is sufficiently large number and most probably users have lost or sold the phone before it reaches those values. How often do you write into this table?
If you really think this will be a problem then add some maintenace cycle to yuor app - create new temporary table, move your existing data to it, drop current table and recreate it. Then move data back to it and drop temporary table. I recommend to pack the database also afterward.

"I only know that I know nothing." (Socrates)

  • Login to reply to this topic.