Bill stated he only had one table. Therefore an identity column would
suffice. For flexibility and extensibility though personally I would always
go for guids in this situation.

Regards

Richard Blewett
DevelopMentor

-----Original Message-----
From: Moderated discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of J. Merrill
Sent: 04 February 2004 19:55
To: [EMAIL PROTECTED]
Subject: Re: [ADVANCED-DOTNET] Ensuring unique keys from multiple DataSets
when updating

Does an identity column fully solve even problem 1?  What value(s) of
CustomerID in the client's Customer table are used to indicate "new
Customer" to the "apply changes" code?  (Null values aren't allowed in an
Identity column.)  If there's a parent/child relationship (that is, 0 or
more Orders for each Customer represented by a 1-to-N relationship;
Order.CustomerID is a FK to Customer.CustomerID), how are they linked to the
parent Customer when we don't know the  CustomerID value that the new
Customer will get via the identity column?

If the rule were "negative values identify rows that need to be added", then
the first new client added could have CustomerID value of -1 and its
children could have their CustomerID linking field set to -1 as well.  (The
second new Customer will be -2, and so on.)  When the dataset updates are
applied, each negative CustomerID value in the Customer table will cause a
new row to be added; but where is there any non-customer code that will know
to modify the negative CustomerID values in the Orders to the identity
value(s) returned when the new customers were added, before trying to add
the Orders?  What if the Order table (with an identity OrderID column) is
parent to an OrderItem table (with an OrderID column that's FK to
Order.OrderID)?

Will the client's copy of the Customer table ever get the identity values
for the new Customer rows that were added by the server?  Will the client's
Order table get those CustomerID values as well (without a full Refresh)?
What about the Order table OrderID values (an identity column) getting moved
down to OrderItem.OrderID in similar fashion?

At 11:51 AM 2/4/2004, Richard Blewett wrote
>The problem here Bill is two fold:
>
>1. Easily solved non duplicate primary key by either using a GUID column or
>an identity column. The nice thing about a guid column is the client can
>create the value and know the insert won't create a duplicate primary key.
>
>2. Here's the more complex problem - can you be sure that A and B won't add
>the same customer, thus creating two database records for the same business
>entity. This is a problem domain specific issue and not one that can be
>solved with a simple general solution.
>
>Regards
>
>Richard Blewett
>DevelopMentor
>
>-----Original Message-----
>From: Moderated discussion of advanced .NET topics.
>[mailto:[EMAIL PROTECTED] On Behalf Of Bill Bassler
>Sent: 04 February 2004 14:46
>To: [EMAIL PROTECTED]
>Subject: [ADVANCED-DOTNET] Ensuring unique keys from multiple DataSets when
>updating
>
>I'm designing an application that has a server running a webservice that
>supplies a dataset through one method, and accepts changes through another.
>The dataset supplied has a primary key on the only one table it contains.
>Now, two clients, "A" and "B", request the dataset, here is how their table
>looks (Identical).
>
>CustomerID          FirstName
>1                   Alpha
>2                   Beta
>
>Both A and B add a row. Since the primary key generated by the datasets
>could be identical or irrelevant, how do I ensure that the database
>generates a consistent primary key?


J. Merrill / Analytical Software Corp

===================================
This list is hosted by DevelopMentor.  http://www.develop.com
Some .NET courses you may be interested in:

NEW! Guerrilla ASP.NET, 26 Jan 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls

View archives and manage your subscription(s) at http://discuss.develop.com

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.576 / Virus Database: 365 - Release Date: 30/01/2004
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.576 / Virus Database: 365 - Release Date: 30/01/2004
 

===================================
This list is hosted by DevelopMentor®  http://www.develop.com
Some .NET courses you may be interested in:

NEW! Guerrilla ASP.NET, 26 Jan 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to