context: vb6/ ado / .mdb format / jet 4.0 (not using Access - ADO only)
- creating tables via ADO (don't have access)
- all tables have a primary key (PK)
- many of the PK will become FK(Foreign Key) in other table(s)
- record entries will be made via ADO
I am soliciting opinions on the pros and cons of using AUTOINCREMENT
versus code generated GUID or LONG value
(as far as my limited understanding goes, if I enter a record, and need to
also make other linked entries in other tables, I need to retrieve the PK
which was just entered, save it to a variable, then make the succeeding
entries in the other tables using that variable for the FK field...is that
right?
I don't know much about stored procedures, but I read that in order to
retrieve the PK of a newly entered record, some rigamerole of a stored
proceedure and @@identity must be involved to get the PK of a newly entered
record...
which seems more complicated than just generating a guid, saving to a
variable, then using that variable for all the entries in all the tables
that need to be linked with that PK/FK...but that's just my inexperienced
thoughts on the matter)
opinions found on google:
1)
1/18/2000 Berni
"We have solved that problem in another way:
We use GUID for the ID-Field although they are bigger!
That has several advantages:
- We generate the number at first, so we dont need to retrieve it from the
server - it is faster, no stored proc, ..
- we are able to join separate generated tables - never double ID's .
- we are SQL-Provider independent (Oracle, SQL-Server or Access have all
different ways to use Autoincrement fields)
"
2)
Jeff Hedrick 1-18-2001
(microsoft.public.vb.database.ado)
I have found autoincrement columns to be problematic. While great for
conversion and population, some providers including SQL Svr seem to loose
their "seed" during operational problems. Also, determining the value after
an insertion is often impossible because of the global nature of this
variable in the data server
One thing I have noticed is that if the "counter" column is indexed, that
a query limited to returning one row in a DESC (descending) manner seems to
execute very rapidly. So, you can easily determine the last value in the
Table. Again, high volume multi-user environments can be a problem because
of the 2-stage nature.
Finally, a counter maintained in a separate table seems to be best. For
one thing, you can update it pessimistically. This value can easily be
determined as per above if corruption is suspected. (i.e. an insertion
encounters a problem) As a side advantage, you can seed your counter(s)
without having to seed the data server.
in reference to opinion 2 above, where he says "Finally, a counter
maintained in a separate table seems to be best"
I'm not sure what he means by that...
does that mean one creates (for example): tblCounter with a fldCurrentIndex
then every time a record needs to be added to another table, one has to get
the max value from tblCounter.fldCurrentIndex, add one to it, add that to
the next record in tblCounter and then use that value for your other
'actual' table entries???
other opinions?
tia
Mark 3 3012
The random GUID is primarily there for replication. If you are not using a
replicated database at disparate sites, you don't need it.
The AutoNumber value will be available in the recordset you added the record
to immediately after you add it.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"MP" <no****@Thanks.com> wrote in message
news:Qt*****************@tornado.rdc-kc.rr.com... context: vb6/ ado / .mdb format / jet 4.0 (not using Access - ADO only)
- creating tables via ADO (don't have access) - all tables have a primary key (PK) - many of the PK will become FK(Foreign Key) in other table(s) - record entries will be made via ADO
I am soliciting opinions on the pros and cons of using AUTOINCREMENT versus code generated GUID or LONG value (as far as my limited understanding goes, if I enter a record, and need to also make other linked entries in other tables, I need to retrieve the PK which was just entered, save it to a variable, then make the succeeding entries in the other tables using that variable for the FK field...is that right? I don't know much about stored procedures, but I read that in order to retrieve the PK of a newly entered record, some rigamerole of a stored proceedure and @@identity must be involved to get the PK of a newly entered record... which seems more complicated than just generating a guid, saving to a variable, then using that variable for all the entries in all the tables that need to be linked with that PK/FK...but that's just my inexperienced thoughts on the matter) opinions found on google: 1) 1/18/2000 Berni "We have solved that problem in another way: We use GUID for the ID-Field although they are bigger! That has several advantages: - We generate the number at first, so we dont need to retrieve it from the server - it is faster, no stored proc, .. - we are able to join separate generated tables - never double ID's . - we are SQL-Provider independent (Oracle, SQL-Server or Access have all different ways to use Autoincrement fields) "
2) Jeff Hedrick 1-18-2001 (microsoft.public.vb.database.ado) I have found autoincrement columns to be problematic. While great for conversion and population, some providers including SQL Svr seem to loose their "seed" during operational problems. Also, determining the value after an insertion is often impossible because of the global nature of this variable in the data server One thing I have noticed is that if the "counter" column is indexed, that a query limited to returning one row in a DESC (descending) manner seems to execute very rapidly. So, you can easily determine the last value in the Table. Again, high volume multi-user environments can be a problem because of the 2-stage nature. Finally, a counter maintained in a separate table seems to be best. For one thing, you can update it pessimistically. This value can easily be determined as per above if corruption is suspected. (i.e. an insertion encounters a problem) As a side advantage, you can seed your counter(s) without having to seed the data server.
in reference to opinion 2 above, where he says "Finally, a counter maintained in a separate table seems to be best" I'm not sure what he means by that... does that mean one creates (for example): tblCounter with a fldCurrentIndex then every time a record needs to be added to another table, one has to get the max value from tblCounter.fldCurrentIndex, add one to it, add that to the next record in tblCounter and then use that value for your other 'actual' table entries???
other opinions?
tia Mark
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:43***********************@per-qv1-newsreader-01.iinet.net.au... The random GUID is primarily there for replication. If you are not using a replicated database at disparate sites, you don't need it.
The AutoNumber value will be available in the recordset you added the
record to immediately after you add it.
Thanks Allen,
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in
news:43***********************@per-qv1-newsreader-01.iinet.net.au: The random GUID is primarily there for replication. If you are not using a replicated database at disparate sites, you don't need it.
You don't need it at all. There is no reason to use the GUID
Autonumber in any Access application, as it leads to myriad problems
and accomplishes nothing significant.
--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: jaYPee |
last post by:
I have a table in my sqlserver 2000 that has a field IDNO. i want this
field to be my primary key. however i don't want this field to use the
autoincrement feature. when i access this table from...
|
by: Mary Walker |
last post by:
Hi,
I'm enclosed a snippet of test code which highlights my problem. The Stored
procedure insertValue should insert text into the parent, then insert other
text into the child table but the 2...
|
by: Sky |
last post by:
Hello,
The books on C# I have read talk of using the DataSets in disconnected mode,
and Adding/Removing/Updating records from it, and letting it handle all the
updating on the Database in one...
|
by: Neil |
last post by:
Hi,
I'm getting some strange results using the autoincrement column on my
datatable. I'm populating a datatable with data from my database and
displaying this in a datagrid. The first time I get...
|
by: Dennis |
last post by:
I have set a DataTable and one of the columns I set "AutoIncrement" to True.
I then populate the Table by setting the columns to values then add the row
to the table. I inadverently set the...
|
by: Michael |
last post by:
I am trying to create an access database within Net 2003 using the ADOX
library which works fine except when I try to add the AutoIncrement property
to the ContactId column.
I am experiencing a...
|
by: JC Voon |
last post by:
Hi:
How to reset the autoincrement value generated by DataTable ?
I've master and detail table, the detail table has a autoincrement
column, each time i add a new master record, i need to...
|
by: Tim |
last post by:
Hello All, I could use some help on an error that is just now popping it's
head up.
Seems that the autoincrement numeric has hit 32,767. The autoincrement is
used in various locations in the...
|
by: rizwan6feb |
last post by:
I have a DataTable with thousands of records, i want to show these records on per page basis ( i.e a DataGridView showing first 20 records and next button to show next 20 records ...)
To achieve...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
| |