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

Cascade Updates With Primary Keys

Help! I understand how primary keys work, but may need some creative
thinking to help with this. Can't be first time it was asked.

I have a streets table with a primary key of street ID. Table is like
below:

Street ID Street Address
ID1 6 Blank Way
ID2 9 Waters Way
ID3 6 Blan Way

The Primary key is linked to about 9 other tables in the relationships
window with cascade updates. Looking at the above, I've determined
that ID1 and ID3 are the same. So I want to reassign everyone that has
ID3 to ID1. Then I want to remove ID3 from the table since it's no
good.

I can't just change ID3 to ID1 since it's a master key. If I add an
autonumber field to this table and make the 2 of these fields a key,
that might allow me to change ID3 to ID1, but I wouldn't think it would
let me delete ID3 (now ID1) since that's linked to other tables.

I dont want to have to write 9 queries to tell all my tables to change
ID3 to ID1. I know I could do that, but the point of the cascade
updates is so I wont' have to do that. I don't really know VB.

Any help that can be provided is much appreciated!

Nov 16 '06 #1
4 1926
On 16 Nov 2006 10:36:09 -0800, "ve***@aol.com" <ve***@aol.comwrote:
>Help! I understand how primary keys work, but may need some creative
thinking to help with this. Can't be first time it was asked.

I have a streets table with a primary key of street ID. Table is like
below:

Street ID Street Address
ID1 6 Blank Way
ID2 9 Waters Way
ID3 6 Blan Way

The Primary key is linked to about 9 other tables in the relationships
window with cascade updates. Looking at the above, I've determined
that ID1 and ID3 are the same. So I want to reassign everyone that has
ID3 to ID1. Then I want to remove ID3 from the table since it's no
good.

I can't just change ID3 to ID1 since it's a master key. If I add an
autonumber field to this table and make the 2 of these fields a key,
that might allow me to change ID3 to ID1, but I wouldn't think it would
let me delete ID3 (now ID1) since that's linked to other tables.

I dont want to have to write 9 queries to tell all my tables to change
ID3 to ID1. I know I could do that, but the point of the cascade
updates is so I wont' have to do that. I don't really know VB.

Any help that can be provided is much appreciated!
Nov 16 '06 #2
On Thu, 16 Nov 2006 12:52:07 -0700, Tom van Stiphout
<no*************@cox.netwrote:

(Sorry for previous post - I hit the wrong key)

The nine queries is your best idea. Of course you would make them
parameter queries so you can re-use them for any other pair of ID
values. Depending on your skills, you could even produce a "Database
Cleanup" form where the user can select the two ID values, click the
"Fix" button, and your queries do the work, looking back at this form
for their parameters.

If you want to automate this, learning VBA is the only way to go.

-Tom.
>On 16 Nov 2006 10:36:09 -0800, "ve***@aol.com" <ve***@aol.comwrote:
>>Help! I understand how primary keys work, but may need some creative
thinking to help with this. Can't be first time it was asked.

I have a streets table with a primary key of street ID. Table is like
below:

Street ID Street Address
ID1 6 Blank Way
ID2 9 Waters Way
ID3 6 Blan Way

The Primary key is linked to about 9 other tables in the relationships
window with cascade updates. Looking at the above, I've determined
that ID1 and ID3 are the same. So I want to reassign everyone that has
ID3 to ID1. Then I want to remove ID3 from the table since it's no
good.

I can't just change ID3 to ID1 since it's a master key. If I add an
autonumber field to this table and make the 2 of these fields a key,
that might allow me to change ID3 to ID1, but I wouldn't think it would
let me delete ID3 (now ID1) since that's linked to other tables.

I dont want to have to write 9 queries to tell all my tables to change
ID3 to ID1. I know I could do that, but the point of the cascade
updates is so I wont' have to do that. I don't really know VB.

Any help that can be provided is much appreciated!
Nov 16 '06 #3
I might have dumbed down my skills a little too much. I was hoping not
to have to do the 9 queries. Yes, I did do similar in past and have a
table with old to new ID. Can certainly fix them all with a macro.
It's just each time this comes up it has to be run, etc. If that's
definitely only way and no one can think of anything else, so be it I
guess. Thanks!
Tom van Stiphout wrote:
On Thu, 16 Nov 2006 12:52:07 -0700, Tom van Stiphout
<no*************@cox.netwrote:

(Sorry for previous post - I hit the wrong key)

The nine queries is your best idea. Of course you would make them
parameter queries so you can re-use them for any other pair of ID
values. Depending on your skills, you could even produce a "Database
Cleanup" form where the user can select the two ID values, click the
"Fix" button, and your queries do the work, looking back at this form
for their parameters.

If you want to automate this, learning VBA is the only way to go.

-Tom.
On 16 Nov 2006 10:36:09 -0800, "ve***@aol.com" <ve***@aol.comwrote:
>Help! I understand how primary keys work, but may need some creative
thinking to help with this. Can't be first time it was asked.

I have a streets table with a primary key of street ID. Table is like
below:

Street ID Street Address
ID1 6 Blank Way
ID2 9 Waters Way
ID3 6 Blan Way

The Primary key is linked to about 9 other tables in the relationships
window with cascade updates. Looking at the above, I've determined
that ID1 and ID3 are the same. So I want to reassign everyone that has
ID3 to ID1. Then I want to remove ID3 from the table since it's no
good.

I can't just change ID3 to ID1 since it's a master key. If I add an
autonumber field to this table and make the 2 of these fields a key,
that might allow me to change ID3 to ID1, but I wouldn't think it would
let me delete ID3 (now ID1) since that's linked to other tables.

I dont want to have to write 9 queries to tell all my tables to change
ID3 to ID1. I know I could do that, but the point of the cascade
updates is so I wont' have to do that. I don't really know VB.

Any help that can be provided is much appreciated!
Nov 16 '06 #4
I agree with Tom, you don't have any other options than run the 9
queries. My only suggestion would be to put these into a function, and
wrap the queries within a workspace Transaction, so that they all
update, or rollback on any failure.

Nov 20 '06 #5

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

Similar topics

0
by: Fraser Hanson | last post by:
Hello, I have a table which has a foreign key relationship with itself. I want and expect my updates to cascade (deletes definitely cascade as expected) but instead I just get error 1217:...
1
by: Andrew DeFaria | last post by:
I created the following .sql file to demonstrate a problem I'm having. According to the manual: If |ON DELETE CASCADE| is specified, and a row in the parent table is deleted, then InnoDB...
2
by: Gunnar Vøyenli | last post by:
Hi! For the sake of simplicity, I have three tables, Employee, Department and Work Employee >---- Department \ / \ / ^ ^ Work
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...
7
by: Aaron Smith | last post by:
Is there a way to do this safely? I'm using MSDE and have two tables that are linked via 3 fields. If one of those fields change, I need the update to cascade through the child file. There is a...
2
by: R.Welz | last post by:
Hello. I want to discuss a problem I have with my database design becourse I feel I cannot decide wheather I am on the right way of doing things. First of all, I am writing a literature and...
5
by: Michael Fuhr | last post by:
I'd like to propose that certain GRANTs on a table cascade to the table's implicit sequences. In the current implementation (as of 7.4.5 and 8.0.0beta3), a table owner must typically issue GRANT...
26
by: Allen Browne | last post by:
In Access 2000 and later, you can create a relation between tables where related records can be automatically set to Null rather than deleted when the primary record is deleted. I have not seen...
3
by: blakerrr | last post by:
Hello World! I'm a rookie with access and my green skin needs a little help. I have two tables, one called BOM and one called Junction. BOM contains parts and assemblies and subassemblies info and...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...

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.