By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,872 Members | 2,392 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,872 IT Pros & Developers. It's quick & easy.

Cascade updates on primary keys..

P: n/a
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 relation on the
tables on the server and on the tables in the dataset... Every time I
try to do an Update, if those fields have changed or if none have
changed, I get this error: "The query processor cound not produce a
query plan from the optimizer because a query cannot update a text,
ntext, or image column and a clustering key at the same time. I remember
having this before and I had to remove the key columns from the update
command, however that was a situation where the primary key will never
change. This one will...

I don't know if it's related or not, but doing an AddNew on the
bindingcontext of the parent file no longer adds a new row. It gets
added, but the current position is always 0. Trying to navigate to that
row doesn't work either...

Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a

You shouldn't link tables on multiple fields--it's a non-normalized
and waisteful design. Define a single primary key field such as an
int identity field and use that as the fk to the other table.

If you need to maintain uniqueness on the other three fields define a
unique constraint--they don't need to be the pk to be unique.

HTH,

Sam
On Fri, 17 Dec 2004 17:02:23 GMT, Aaron Smith
<th**********@smithcentral.net> wrote:
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 relation on the
tables on the server and on the tables in the dataset... Every time I
try to do an Update, if those fields have changed or if none have
changed, I get this error: "The query processor cound not produce a
query plan from the optimizer because a query cannot update a text,
ntext, or image column and a clustering key at the same time. I remember
having this before and I had to remove the key columns from the update
command, however that was a situation where the primary key will never
change. This one will...

I don't know if it's related or not, but doing an AddNew on the
bindingcontext of the parent file no longer adds a new row. It gets
added, but the current position is always 0. Trying to navigate to that
row doesn't work either...

Aaron


Nov 21 '05 #2

P: n/a

"Samuel R. Neff" <bl****@newsgroup.nospam> wrote in message
news:fc********************************@4ax.com...

You shouldn't link tables on multiple fields--it's a non-normalized
and waisteful design. Define a single primary key field such as an
int identity field and use that as the fk to the other table.


1) There's nothing "non-normalized" about a compound primary key.

2) There's nothing "wasteful" about a compound primary key.

But,

3) Primary keys should be immutable, and should never use cascade updates.

So if you must update a compound key, you will need to introduce a surrogate
primary key (eg int identity primary key).
David
Nov 21 '05 #3

P: n/a

When the primary key is used as a foreign key in another table, then
the use of a compound primary key is both wasteful and
non-normalized--it duplicates data unnecessarily.

Sam

On Fri, 17 Dec 2004 13:20:12 -0600, "David Browne" <davidbaxterbrowne
no potted me**@hotmail.com> wrote:

"Samuel R. Neff" <bl****@newsgroup.nospam> wrote in message
news:fc********************************@4ax.com.. .

You shouldn't link tables on multiple fields--it's a non-normalized
and waisteful design. Define a single primary key field such as an
int identity field and use that as the fk to the other table.


1) There's nothing "non-normalized" about a compound primary key.

2) There's nothing "wasteful" about a compound primary key.

But,

3) Primary keys should be immutable, and should never use cascade updates.

So if you must update a compound key, you will need to introduce a surrogate
primary key (eg int identity primary key).
David


Nov 21 '05 #4

P: n/a

"Samuel R. Neff" <bl****@newsgroup.nospam> wrote in message
news:91********************************@4ax.com...

When the primary key is used as a foreign key in another table, then
the use of a compound primary key is both wasteful and
non-normalized--it duplicates data unnecessarily.


It's not "non-normalized" because the rules for normalization take no notice
of whether a key is simple or compound. It just doesn't affect the
normalization.

It's not "wasteful" beacuse what you loose in storing the longer foreign key
on the table, you often make up for in having fewer total indexes on the
tables. Also it simplifies and dramatically speeds filtering the related
table by the compound key columns.
EG

select sum(amount)
from order_details
where customer = 1

instead of

select sum(amount)
from order_details
where order_id in ( select id
from order
where customer = 1)

David
Nov 21 '05 #5

P: n/a
Hi Sam,

I would be interested in knowing how to create a unique constraint on a
field without making the field the PK.

Thanks,

Francois
"Samuel R. Neff" <bl****@newsgroup.nospam> wrote in message
news:fc********************************@4ax.com...

You shouldn't link tables on multiple fields--it's a non-normalized
and waisteful design. Define a single primary key field such as an
int identity field and use that as the fk to the other table.

If you need to maintain uniqueness on the other three fields define a
unique constraint--they don't need to be the pk to be unique.

HTH,

Sam
On Fri, 17 Dec 2004 17:02:23 GMT, Aaron Smith
<th**********@smithcentral.net> wrote:
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 relation on the
tables on the server and on the tables in the dataset... Every time I
try to do an Update, if those fields have changed or if none have
changed, I get this error: "The query processor cound not produce a
query plan from the optimizer because a query cannot update a text,
ntext, or image column and a clustering key at the same time. I remember
having this before and I had to remove the key columns from the update
command, however that was a situation where the primary key will never
change. This one will...

I don't know if it's related or not, but doing an AddNew on the
bindingcontext of the parent file no longer adds a new row. It gets
added, but the current position is always 0. Trying to navigate to that
row doesn't work either...

Aaron

Nov 21 '05 #6

P: n/a

In DDL add the keyword UNIQUE after the contraint name and before the
column names. In EM there's a checkbox for unique.

http://msdn.microsoft.com/library/de...aa-az_3ied.asp

HTH,

Sam

On Mon, 20 Dec 2004 10:54:04 +0700, "Francois"
<fr******@bettinghouses.com_NOSPAM> wrote:
Hi Sam,

I would be interested in knowing how to create a unique constraint on a
field without making the field the PK.

Thanks,

Francois


Nov 21 '05 #7

P: n/a
Tx for that ! :)

Francois.

"Samuel R. Neff" <bl****@newsgroup.nospam> wrote in message
news:gg********************************@4ax.com...

In DDL add the keyword UNIQUE after the contraint name and before the
column names. In EM there's a checkbox for unique.

http://msdn.microsoft.com/library/de...aa-az_3ied.asp
HTH,

Sam

On Mon, 20 Dec 2004 10:54:04 +0700, "Francois"
<fr******@bettinghouses.com_NOSPAM> wrote:
Hi Sam,

I would be interested in knowing how to create a unique constraint on a
field without making the field the PK.

Thanks,

Francois

Nov 21 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.