473,414 Members | 1,948 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,414 software developers and data experts.

Update foreign key before appending records to central database

Looking for suggestions ----

A database was designed for a national automobile inspection program. In
it's simplest form, the database has two tables:
TblOwner
OwnerID
<Year/Make/Model owned by owner, Owner name/address, etc)

TblInspection
InspectionID
OwnerID
<~50 inspection results>

Originally, inspections would be done at a site, a form would be completed
for each inspection and the forms would be sent to a central location to be
entered into the database. 50 to 250 inspections would be done at a site and
50 to 250 forms would be entered into the database for each inspection.
There are approximately 70,000 records in the database currently. The number
of inspections has quickly grown to where it will soon be impossible to
enter all the forms into one central database. The plan now is to enter the
inspections into a dozen satellite databases consisting of TblOwner and
TblInspection and then after each inspection send the database file to the
central database location and append the records in TblOwner and
TblInspection into the same named tables in the central database. The
sattelite database location would then be sent an empty satellite database
to repeat the process. OwnerID and InspectionID would start over at 1.

The problem is in the appending process. With 70,000 records, the last
OwnerID is 70,000 at this point in time. When the first sattellite database
arrives, the OwnerID in TblOwner will start at 1 and end at 250.
Correspondingly, the foreign key, OwnerID in TblInspection, will contain
values of 1 to 250. When TblOwner is appended, all the fields but OwnerID
will be appended to TblOwner in the central database. The Owner records will
have OwnerID values of 70001 to 70250. OwnerID in TblInspection needs to be
updated to the corresponding OwnerID values (70001 to 70250) before the
Inspection records can be appended. The values OwnerID need to be updated to
will continue to increase as each sattelite database arrives. I need
suggestions on how to determine what values to update OwnerID in
TblInspection in the sattelite database to considering that OwnerID in the
TblOwner in the sattelite database may not be contiguous due to the nature
that it's an autonumber field.

Thanks,

Steve
Nov 13 '05 #1
7 2399
Does order of the OwnerID really matter, or can you just create a
random ID for each customer? If you can use random numbers for the
IDs, then I see no reason why creating another field in the parent and
child tables is that big of a deal. Then you can populate the parent
values and cascade them to the children using the existing
relationships. Then if you use the RandomID as your PK in the
different databases, you shouldn't have a problem...

or did I miss a key element here?

Nov 13 '05 #2
Create a set of staging tables with cascading updates
from the primary key field. Import the records to the
staging tables, update the primary key values so that
they don't clash with existing values, then import to
the destination table.

Or use a multifield primary key with a site index.

Or use replication.

Or use random autonumber if you have only 2 or 3 sites.

(replication uses guid's instead of random longs for
more replication sites, but you will regret it if you
try to use guid autonumbers yourself: they are poorly
supported in queries and code)

(david)

"PC Datasheet" <no****@nospam.spam> wrote in message
news:B_******************@newsread2.news.atl.earth link.net...
Looking for suggestions ----

A database was designed for a national automobile inspection program. In
it's simplest form, the database has two tables:
TblOwner
OwnerID
<Year/Make/Model owned by owner, Owner name/address, etc)

TblInspection
InspectionID
OwnerID
<~50 inspection results>

Originally, inspections would be done at a site, a form would be completed
for each inspection and the forms would be sent to a central location to
be entered into the database. 50 to 250 inspections would be done at a
site and 50 to 250 forms would be entered into the database for each
inspection. There are approximately 70,000 records in the database
currently. The number of inspections has quickly grown to where it will
soon be impossible to enter all the forms into one central database. The
plan now is to enter the inspections into a dozen satellite databases
consisting of TblOwner and TblInspection and then after each inspection
send the database file to the central database location and append the
records in TblOwner and TblInspection into the same named tables in the
central database. The sattelite database location would then be sent an
empty satellite database to repeat the process. OwnerID and InspectionID
would start over at 1.

The problem is in the appending process. With 70,000 records, the last
OwnerID is 70,000 at this point in time. When the first sattellite
database arrives, the OwnerID in TblOwner will start at 1 and end at 250.
Correspondingly, the foreign key, OwnerID in TblInspection, will contain
values of 1 to 250. When TblOwner is appended, all the fields but OwnerID
will be appended to TblOwner in the central database. The Owner records
will have OwnerID values of 70001 to 70250. OwnerID in TblInspection needs
to be updated to the corresponding OwnerID values (70001 to 70250) before
the Inspection records can be appended. The values OwnerID need to be
updated to will continue to increase as each sattelite database arrives. I
need suggestions on how to determine what values to update OwnerID in
TblInspection in the sattelite database to considering that OwnerID in the
TblOwner in the sattelite database may not be contiguous due to the nature
that it's an autonumber field.

Thanks,

Steve

Nov 13 '05 #3
My favorite strategy is to use a composite key in the central database that
includes a batch ID and the ID value generated in the remote database. You
generally want the batch ID anyway, so it's not an extra field, though it is a
larger PK index.

On Mon, 12 Sep 2005 14:09:37 GMT, "PC Datasheet" <no****@nospam.spam> wrote:
Looking for suggestions ----

A database was designed for a national automobile inspection program. In
it's simplest form, the database has two tables:
TblOwner
OwnerID
<Year/Make/Model owned by owner, Owner name/address, etc)

TblInspection
InspectionID
OwnerID
<~50 inspection results>

Originally, inspections would be done at a site, a form would be completed
for each inspection and the forms would be sent to a central location to be
entered into the database. 50 to 250 inspections would be done at a site and
50 to 250 forms would be entered into the database for each inspection.
There are approximately 70,000 records in the database currently. The number
of inspections has quickly grown to where it will soon be impossible to
enter all the forms into one central database. The plan now is to enter the
inspections into a dozen satellite databases consisting of TblOwner and
TblInspection and then after each inspection send the database file to the
central database location and append the records in TblOwner and
TblInspection into the same named tables in the central database. The
sattelite database location would then be sent an empty satellite database
to repeat the process. OwnerID and InspectionID would start over at 1.

The problem is in the appending process. With 70,000 records, the last
OwnerID is 70,000 at this point in time. When the first sattellite database
arrives, the OwnerID in TblOwner will start at 1 and end at 250.
Correspondingly, the foreign key, OwnerID in TblInspection, will contain
values of 1 to 250. When TblOwner is appended, all the fields but OwnerID
will be appended to TblOwner in the central database. The Owner records will
have OwnerID values of 70001 to 70250. OwnerID in TblInspection needs to be
updated to the corresponding OwnerID values (70001 to 70250) before the
Inspection records can be appended. The values OwnerID need to be updated to
will continue to increase as each sattelite database arrives. I need
suggestions on how to determine what values to update OwnerID in
TblInspection in the sattelite database to considering that OwnerID in the
TblOwner in the sattelite database may not be contiguous due to the nature
that it's an autonumber field.

Thanks,

Steve


Nov 13 '05 #4
David,

Thanks for responding. Could you give more details about your staging tables
concept.

Thanks!

Steve
"david epsom dot com dot au" <david@epsomdotcomdotau> wrote in message
news:43***********************@lon-reader.news.telstra.net...
Create a set of staging tables with cascading updates
from the primary key field. Import the records to the
staging tables, update the primary key values so that
they don't clash with existing values, then import to
the destination table.

Or use a multifield primary key with a site index.

Or use replication.

Or use random autonumber if you have only 2 or 3 sites.

(replication uses guid's instead of random longs for
more replication sites, but you will regret it if you
try to use guid autonumbers yourself: they are poorly
supported in queries and code)

(david)

"PC Datasheet" <no****@nospam.spam> wrote in message
news:B_******************@newsread2.news.atl.earth link.net...
Looking for suggestions ----

A database was designed for a national automobile inspection program. In
it's simplest form, the database has two tables:
TblOwner
OwnerID
<Year/Make/Model owned by owner, Owner name/address, etc)

TblInspection
InspectionID
OwnerID
<~50 inspection results>

Originally, inspections would be done at a site, a form would be
completed for each inspection and the forms would be sent to a central
location to be entered into the database. 50 to 250 inspections would be
done at a site and 50 to 250 forms would be entered into the database for
each inspection. There are approximately 70,000 records in the database
currently. The number of inspections has quickly grown to where it will
soon be impossible to enter all the forms into one central database. The
plan now is to enter the inspections into a dozen satellite databases
consisting of TblOwner and TblInspection and then after each inspection
send the database file to the central database location and append the
records in TblOwner and TblInspection into the same named tables in the
central database. The sattelite database location would then be sent an
empty satellite database to repeat the process. OwnerID and InspectionID
would start over at 1.

The problem is in the appending process. With 70,000 records, the last
OwnerID is 70,000 at this point in time. When the first sattellite
database arrives, the OwnerID in TblOwner will start at 1 and end at 250.
Correspondingly, the foreign key, OwnerID in TblInspection, will contain
values of 1 to 250. When TblOwner is appended, all the fields but OwnerID
will be appended to TblOwner in the central database. The Owner records
will have OwnerID values of 70001 to 70250. OwnerID in TblInspection
needs to be updated to the corresponding OwnerID values (70001 to 70250)
before the Inspection records can be appended. The values OwnerID need to
be updated to will continue to increase as each sattelite database
arrives. I need suggestions on how to determine what values to update
OwnerID in TblInspection in the sattelite database to considering that
OwnerID in the TblOwner in the sattelite database may not be contiguous
due to the nature that it's an autonumber field.

Thanks,

Steve


Nov 13 '05 #5
Steve,

Thank you for responding! Your startegy seems like it would be good if
starting from scratch but im this case the first batch of owner records will
be appended to the central database and their OwnerIDs will become 70001 to
70250. The foreign key in the inspection records must then take on these
same values.

Steve
"Steve Jorgensen" <no****@nospam.nospam> wrote in message
news:gi********************************@4ax.com...
My favorite strategy is to use a composite key in the central database
that
includes a batch ID and the ID value generated in the remote database.
You
generally want the batch ID anyway, so it's not an extra field, though it
is a
larger PK index.

On Mon, 12 Sep 2005 14:09:37 GMT, "PC Datasheet" <no****@nospam.spam>
wrote:
Looking for suggestions ----

A database was designed for a national automobile inspection program. In
it's simplest form, the database has two tables:
TblOwner
OwnerID
<Year/Make/Model owned by owner, Owner name/address, etc)

TblInspection
InspectionID
OwnerID
<~50 inspection results>

Originally, inspections would be done at a site, a form would be completed
for each inspection and the forms would be sent to a central location to
be
entered into the database. 50 to 250 inspections would be done at a site
and
50 to 250 forms would be entered into the database for each inspection.
There are approximately 70,000 records in the database currently. The
number
of inspections has quickly grown to where it will soon be impossible to
enter all the forms into one central database. The plan now is to enter
the
inspections into a dozen satellite databases consisting of TblOwner and
TblInspection and then after each inspection send the database file to the
central database location and append the records in TblOwner and
TblInspection into the same named tables in the central database. The
sattelite database location would then be sent an empty satellite database
to repeat the process. OwnerID and InspectionID would start over at 1.

The problem is in the appending process. With 70,000 records, the last
OwnerID is 70,000 at this point in time. When the first sattellite
database
arrives, the OwnerID in TblOwner will start at 1 and end at 250.
Correspondingly, the foreign key, OwnerID in TblInspection, will contain
values of 1 to 250. When TblOwner is appended, all the fields but OwnerID
will be appended to TblOwner in the central database. The Owner records
will
have OwnerID values of 70001 to 70250. OwnerID in TblInspection needs to
be
updated to the corresponding OwnerID values (70001 to 70250) before the
Inspection records can be appended. The values OwnerID need to be updated
to
will continue to increase as each sattelite database arrives. I need
suggestions on how to determine what values to update OwnerID in
TblInspection in the sattelite database to considering that OwnerID in the
TblOwner in the sattelite database may not be contiguous due to the nature
that it's an autonumber field.

Thanks,

Steve

Nov 13 '05 #6
Make a copy of the source tables. You can use the
source database, destination database, or third database.

Make sure the tables have cascading update defined
on the relationships. (Change if necessary)
Create an update query for the primary table, which
updates the primary key to [original value] + [offset]
Get the offset in the query by using DMAX() on the
destination table. The cascading update will fix
the dependant tables.

After you have updated the staging tables,
append to the destination tables

Then delete the values from the staging tables,
or discard the database.

(david)

"PC Datasheet" <no****@nospam.spam> wrote in message
news:7B******************@newsread2.news.atl.earth link.net...
David,

Thanks for responding. Could you give more details about your staging
tables concept.

Thanks!

Steve
"david epsom dot com dot au" <david@epsomdotcomdotau> wrote in message
news:43***********************@lon-reader.news.telstra.net...
Create a set of staging tables with cascading updates
from the primary key field. Import the records to the
staging tables, update the primary key values so that
they don't clash with existing values, then import to
the destination table.

Or use a multifield primary key with a site index.

Or use replication.

Or use random autonumber if you have only 2 or 3 sites.

(replication uses guid's instead of random longs for
more replication sites, but you will regret it if you
try to use guid autonumbers yourself: they are poorly
supported in queries and code)

(david)

"PC Datasheet" <no****@nospam.spam> wrote in message
news:B_******************@newsread2.news.atl.earth link.net...
Looking for suggestions ----

A database was designed for a national automobile inspection program. In
it's simplest form, the database has two tables:
TblOwner
OwnerID
<Year/Make/Model owned by owner, Owner name/address, etc)

TblInspection
InspectionID
OwnerID
<~50 inspection results>

Originally, inspections would be done at a site, a form would be
completed for each inspection and the forms would be sent to a central
location to be entered into the database. 50 to 250 inspections would be
done at a site and 50 to 250 forms would be entered into the database
for each inspection. There are approximately 70,000 records in the
database currently. The number of inspections has quickly grown to where
it will soon be impossible to enter all the forms into one central
database. The plan now is to enter the inspections into a dozen
satellite databases consisting of TblOwner and TblInspection and then
after each inspection send the database file to the central database
location and append the records in TblOwner and TblInspection into the
same named tables in the central database. The sattelite database
location would then be sent an empty satellite database to repeat the
process. OwnerID and InspectionID would start over at 1.

The problem is in the appending process. With 70,000 records, the last
OwnerID is 70,000 at this point in time. When the first sattellite
database arrives, the OwnerID in TblOwner will start at 1 and end at
250. Correspondingly, the foreign key, OwnerID in TblInspection, will
contain values of 1 to 250. When TblOwner is appended, all the fields
but OwnerID will be appended to TblOwner in the central database. The
Owner records will have OwnerID values of 70001 to 70250. OwnerID in
TblInspection needs to be updated to the corresponding OwnerID values
(70001 to 70250) before the Inspection records can be appended. The
values OwnerID need to be updated to will continue to increase as each
sattelite database arrives. I need suggestions on how to determine what
values to update OwnerID in TblInspection in the sattelite database to
considering that OwnerID in the TblOwner in the sattelite database may
not be contiguous due to the nature that it's an autonumber field.

Thanks,

Steve



Nov 13 '05 #7
Thanks, David, appreciate the help!

Steve

"david epsom dot com dot au" <david@epsomdotcomdotau> wrote in message
news:43***********************@lon-reader.news.telstra.net...
Make a copy of the source tables. You can use the
source database, destination database, or third database.

Make sure the tables have cascading update defined
on the relationships. (Change if necessary)
Create an update query for the primary table, which
updates the primary key to [original value] + [offset]
Get the offset in the query by using DMAX() on the
destination table. The cascading update will fix
the dependant tables.

After you have updated the staging tables,
append to the destination tables

Then delete the values from the staging tables,
or discard the database.

(david)

"PC Datasheet" <no****@nospam.spam> wrote in message
news:7B******************@newsread2.news.atl.earth link.net...
David,

Thanks for responding. Could you give more details about your staging
tables concept.

Thanks!

Steve
"david epsom dot com dot au" <david@epsomdotcomdotau> wrote in message
news:43***********************@lon-reader.news.telstra.net...
Create a set of staging tables with cascading updates
from the primary key field. Import the records to the
staging tables, update the primary key values so that
they don't clash with existing values, then import to
the destination table.

Or use a multifield primary key with a site index.

Or use replication.

Or use random autonumber if you have only 2 or 3 sites.

(replication uses guid's instead of random longs for
more replication sites, but you will regret it if you
try to use guid autonumbers yourself: they are poorly
supported in queries and code)

(david)

"PC Datasheet" <no****@nospam.spam> wrote in message
news:B_******************@newsread2.news.atl.earth link.net...
Looking for suggestions ----

A database was designed for a national automobile inspection program.
In it's simplest form, the database has two tables:
TblOwner
OwnerID
<Year/Make/Model owned by owner, Owner name/address, etc)

TblInspection
InspectionID
OwnerID
<~50 inspection results>

Originally, inspections would be done at a site, a form would be
completed for each inspection and the forms would be sent to a central
location to be entered into the database. 50 to 250 inspections would
be done at a site and 50 to 250 forms would be entered into the
database for each inspection. There are approximately 70,000 records in
the database currently. The number of inspections has quickly grown to
where it will soon be impossible to enter all the forms into one
central database. The plan now is to enter the inspections into a dozen
satellite databases consisting of TblOwner and TblInspection and then
after each inspection send the database file to the central database
location and append the records in TblOwner and TblInspection into the
same named tables in the central database. The sattelite database
location would then be sent an empty satellite database to repeat the
process. OwnerID and InspectionID would start over at 1.

The problem is in the appending process. With 70,000 records, the last
OwnerID is 70,000 at this point in time. When the first sattellite
database arrives, the OwnerID in TblOwner will start at 1 and end at
250. Correspondingly, the foreign key, OwnerID in TblInspection, will
contain values of 1 to 250. When TblOwner is appended, all the fields
but OwnerID will be appended to TblOwner in the central database. The
Owner records will have OwnerID values of 70001 to 70250. OwnerID in
TblInspection needs to be updated to the corresponding OwnerID values
(70001 to 70250) before the Inspection records can be appended. The
values OwnerID need to be updated to will continue to increase as each
sattelite database arrives. I need suggestions on how to determine what
values to update OwnerID in TblInspection in the sattelite database to
considering that OwnerID in the TblOwner in the sattelite database may
not be contiguous due to the nature that it's an autonumber field.

Thanks,

Steve



Nov 13 '05 #8

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

Similar topics

2
by: Ralph Smith | last post by:
I'm having trouble copying a database to another machine. Here are the two table's in ths database and the sql commands: DROP TABLE IF EXISTS `clients`; CREATE TABLE `clients` ( `client_id`...
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
9
by: Dom Boyce | last post by:
Hi First up, I am using MS Access 2002. I have a database which records analyst rating changes for a list of companies on a daily basis. Unfortunately, the database has been set up (by my...
33
by: Lee C. | last post by:
I'm finding this to be extremely difficult to set up. I understand that Access won't manage the primary key and the cascade updates for a table. Fine. I tried changing the PK type to number and...
0
by: M. David Johnson | last post by:
I cannot get my OleDbDataAdapter to update my database table from my local dataset table. The Knowledge Base doesn't seem to help - see item 10 below. I have a Microsoft Access 2000 database...
30
by: Charles Law | last post by:
Here's one that should probably have the sub-heading "I'm sure I asked this once before, but ...". Two users are both looking at the same data, from a database. One user changes the data and...
0
by: jon | last post by:
Hi there, I'm brand new to Access and may be trying to do too much too soon, but I wanted to get some expert advice on how the best way to go about what I am trying to accomplish would be. I...
1
by: jeffro | last post by:
I have a database used for recording survey data. In the database, I have a form that displays a survey participant and a subform that is filled in by selecting a question from a looklist and...
16
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.