Re: Best Practice: Table Primary Key

From: Cowboy (NoSpamMgbworld_at_comcast.netNoSpamM)
Date: 06/02/04


Date: Wed, 2 Jun 2004 07:43:10 -0500

You have a couple of choices, as I see it.

1. Do not create keys on the client side and allow the database to solve
that when you send data back. This gets increasingly difficult when you deal
with multiple tables offline.

2. Use GUIDs, which are a bit clunkier, but guarantee uniqueness. If you
really have to have unique, this is a good method.

3. Use MSDE on the client and work up replication between client and server.
This is not the greatest offline solution, however. You could, however, make
a sync utility and add a certain amount of numbers to the MSDE database when
you attempt a sync and then have the MSDE autoincrement, but sync at the
next higher number in SQL Server. This may get difficult in some situations.

-- 
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
************************************************
Think Outside the Box!
************************************************
"a" <a@a.com> wrote in message news:OSdxJsJSEHA.3504@TK2MSFTNGP09.phx.gbl...
> Hi gang,
>
> I need some SOLID direction here.
>
> I am planning to use DataSets and DataBinding in an app which will have a
> few users (VB.NET / SQL Server).  I need to be able to create an 'offline'
> mode, where they do not have access to the WebService, and would therfore
> need to store the data locally as XML, then merge into the DB later.
>
> My issue relates to primary keys.  As a former Access Guy (current app is
> SQL Server 2000), I have grown accustomed to the use of Auto-Incrementing
> primary keys for a table, then making relationships to this integer value.
> In .NET Datasets, I know (painfully) that I would need to set the
> AutoincrementStep and AutoincrementSeed of the dataset to -1 and 0, to
avoid
> issues.  This doesn't work for me here, since I need the PrimaryKeys to be
> the same in the 'offline' xml file and the online DB.
>
> I am willing to change my ways, and begin to use either 'natural' keys, or
> GUID fields.  I would like some people to share their experience on using
> either of these is similar situations.  Are there performance hits
> asssociated with relating tables to VARCHAR fields as oposed to INTs?  Are
> there any trade-offs I need to be aware of prior to using this approach?
> Should I 'never use an AutoIncrement again'? Does databinding have any
> issues using a GUID as the Value of a combobox, for example?
>
>
> Thanks!!
>
> Kevin
>
>


Relevant Pages

  • Re: Key attributes with list values was Re: What are the differences ...KEY
    ... Jane Harper is married. ... And a constraint that states that single people cannot become divorced. ... database, or users, for that matter, to distinguish between them. ... That's the whole point of keys. ...
    (comp.databases.theory)
  • Re: Pin generation algorithm question
    ... the keys would be a big ... Suppose that we have a database that contains all valid numbers, ... load among several servers that all need access to this database. ... So the only real problem is which systems are accessing this crypto box. ...
    (sci.crypt)
  • Re: Database design, Keys and some other things
    ... >> Or 'the database has no opinion as what Donald Trump's e-mail address might ... some keys can be wrong or a data can ... Meaning is not related to just one number. ... > is concerned a VIN is not a surrogate key, ...
    (comp.databases.theory)
  • Re: Key attributes with list values was Re: What are the differences ...KEY
    ... database, or users, for that matter, to distinguish between them. ... That's the whole point of keys. ... But that is true of any constraint. ... keys can change, then either updates must be singular, that is, must affect ...
    (comp.databases.theory)
  • Re: Pin generation algorithm question
    ... > You have to secure a number of keys in this instance, ... > tokens in the database with a secret key cipher, or better a keyed hash, and ... Assume that an attacker can monitor requests and observe the ...
    (sci.crypt)