> Hi Penny. That's good it's settled. Also try reinstalling OE first before
> Windows.
[quoted text clipped - 42 lines]
>
> Penny
> It's funny, when designing databases I always (except for lookup
> tables) put a autonumber field as the PK in every table and create
> the constraints in code. . . .
You mean you don't use indexes in the table definitions to properly
restrict entries in candidate keys that could have been the PK? I
agree that Autonumbers as surrogate keys are much easier to use
(replicated or not), but you still need to enforce the appropriate
degree of uniqueness in any candidate keys. Why you'd do that in
code, I can't imagine, because that means that the validity of your
data is dependent on someone using the application you've designed
for it. I think that's bad design -- your basic schema should
prevent the addition of incorrect data (insofar as it's possible
whatever db engine you're using; i.e., some kinds of business rules
would require triggers, which Jet doesn't have), in order that the
database can be used with any application written against it without
danger of corrupting that data.
> . . . That way I'm never tempted to use it as
> real data and get into a situation like you are in. But in your
> case, for all the work/risks involved, and also especially since
> the CandidateID field needs to be sequential, I would be putting
> my effort into working out something like "Request and Append"
> method.
I don't think Penny's situation is unusual in any way. Nor do I
think her approach to it mistaken at all. If, for instance, you want
invoice numbers to be sequential, you're going to be generating your
own invoice number in code, and that's going to present problems for
adding invoices in multiple replicas simultaneously that have to be
addressed. There is nothing wrong there with having data in your
tables that has to be populated in code that is visible to the user.
It definitely *is* the case that it's almost never appropriate to
use an AutoNumber field for anything other than linking tables,
whether or not your back end is replicated.
And Penny is migrating from that.
That was the point of her first post, asking how to do that.
> Taking a step back and looking at it objectively, lets see, your
> design is properly SQL normalised and works fine now. You want to
> make it replicatable. The problem is you want to keep the
> CandidateID sequential in the replicated environment. Right?
She already knew the solution to part of the problem, which was
switching to a random Autonumber PK in the parent table in order to
make relationship enforcement easier.
> Option A: Add a new autonumber PK to every table.
Every table? Why?
Assuming there's only one table that needs a sequential number
viewable by the users before replication, surely only that table
used a non-Autonumber PK in the first place. The only option is
generating the sequence for every table.
But Penny did not say she was generating the sequential PK for
anything but a single table, tblCandidates.
So, I think you presumption that there's any need to add an
Autonumber PK to anything but the one table is mistaken.
> Work? Lots. Plus you also now have to create the table constraints
> in code. . . .
Eh? What table constraints are you talking about? Assuming that she
was using a generated sequential PK in all her tables (not just as
foreign key from a single parent table), an assumption that is
completely unwarranted based on Penny's original post, then
replacing those keys with an Autonumber adds no new constraints at
all, as you're replacing a code-generated key with an engine-created
random key.
There are no additional restraints on any other fields other than
what would have been there in a non-replicated environment.
> . . . Risks? High. Too many to list, and when do you update the
> front end for the new design? You have to kick the users out until
> your finished. . . .
Excuse me?
Doing this kind of update requires some planning. Any schema-related
update requires it.
First off, the front end should not be shared, so you won't have to
kick anybody out of the front end to make changes to the front end
required by changes in the schema.
Second, when the schema changes you need a new front end, replicated
or not. That means that it's best to roll out a pre-schema-change
front end that checks for evidence of the new schema having been
implemented, and if it finds it, tells the user that they must
upgrade to front end to the new version, and otherwise exits (that's
assuming the schema changes are incompatible with the old
application version). Or, if you're already using some for of
automatic update for the front end (such as Tony Toews auto
updater), all you have to do is coordinate the roll-out of the front
end with the synch between the production replica and the design
master.
Third, that would be the case regardless of whether or not the
application were replicated. The advantage to the replicated
scenario is that you can propagate the schema changes via a synch,
instead of having to use code or do them manually.
Fourth, rolling out schema changes of any kind, replicated or
unreplicated, requires kicking users out of the database.
> . . . Fix problem? No. Replica A can still create new
> records, incrementing the CandidateID number at the same time as
> Replica B. Therefore creating duplicates.
See above. These problems are by no means specific to replication --
they are all caused by changes to the schema.
> Option B: Leave the fields alone and create a design that allows
> only one replica to add records.
[quoted text clipped - 4 lines]
> users. Fix problem? Yes. The CandidateID is again guaranteed to be
> sequential.
There is still going to be downtime to the end users if you have any
schema changes to existing tables. If you want RI enforced in the
new tables that implement your independent solution, that can only
be implemented by kicking users out of the data file.
> Anyway, it's your choice and I hope it works out well for you. :)
I am really confused by the kinds of comments you are making here.
They seem to me to be very strange, and completely missing the point
of the original problem, despite my having pointed this out to you
several times.
Are you trying to confuse the matter here or are you trying to help?
From where I sit, it doesn't look like the latter.

Signature
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Cheval - 16 Jul 2005 00:51 GMT
David,
"You mean you don't use indexes in the table definitions to properly
restrict entries in candidate keys that could have been the PK?"
No. I use indexes in the fields that need them. I mean that due to the PK
being a single autonumber field, if the true key is multi-column then I
enforce the multi-column uniqueness in code.
Actually you got me thinking. I just created three tables in a temp
database. Two tables with multi-column PK fields and an non-duplicate
autonumber field and a third with the autonumber foreign fields from the
other two. While it doesn't look the way I expect in the relationships
window it does work and saves me from the constraints coding. I shall give
that good consideration in future Access databases. Thanks.
""> Option A: Add a new autonumber PK to every table.""
"Every table? Why?...But Penny did not say she was generating the sequential
PK for anything but a single table, tblCandidates. So, I think you
presumption that there's any need to add an Autonumber PK to anything but
the one table is mistaken."
As per Penny's response "I am going with adding the Autonumber to all
pertinent tables (which I will ALWAYS do in future)"
> Work? Lots. Plus you also now have to create the table constraints
> in code. . . .
"Eh? What table constraints are you talking about? "
As she said that she will change other tables as well, then if she changes
tables with multi-column keys, then yes this will be the case.
> . . . Risks? High. Too many to list, and when do you update the
> front end for the new design? You have to kick the users out until
> your finished. . . .
"Excuse me?"
Again you answered your own question. There are a lot of steps that need to
take place in certain sequences and many places to make a mistake that can
create headaches for Penny and the users.
"Are you trying to confuse the matter here or are you trying to help? From
where I sit, it doesn't look like the latter."
Oh well, I guess then that I hope to help Penny and confuse you. :) But at
least your thinking and keeping me on my toes.
"Cheval" <NoSpam.Ask@ForEmail.com> wrote in
news:ovgBe.45023$oJ.33974@news-server.bigpond.net.au:
> It's funny, when designing databases I always (except for lookup
> tables) put a autonumber field as the PK in every table and create
> the constraints in code. . . .
You mean you don't use indexes in the table definitions to properly
restrict entries in candidate keys that could have been the PK? I
agree that Autonumbers as surrogate keys are much easier to use
(replicated or not), but you still need to enforce the appropriate
degree of uniqueness in any candidate keys. Why you'd do that in
code, I can't imagine, because that means that the validity of your
data is dependent on someone using the application you've designed
for it. I think that's bad design -- your basic schema should
prevent the addition of incorrect data (insofar as it's possible
whatever db engine you're using; i.e., some kinds of business rules
would require triggers, which Jet doesn't have), in order that the
database can be used with any application written against it without
danger of corrupting that data.
> . . . That way I'm never tempted to use it as
> real data and get into a situation like you are in. But in your
> case, for all the work/risks involved, and also especially since
> the CandidateID field needs to be sequential, I would be putting
> my effort into working out something like "Request and Append"
> method.
I don't think Penny's situation is unusual in any way. Nor do I
think her approach to it mistaken at all. If, for instance, you want
invoice numbers to be sequential, you're going to be generating your
own invoice number in code, and that's going to present problems for
adding invoices in multiple replicas simultaneously that have to be
addressed. There is nothing wrong there with having data in your
tables that has to be populated in code that is visible to the user.
It definitely *is* the case that it's almost never appropriate to
use an AutoNumber field for anything other than linking tables,
whether or not your back end is replicated.
And Penny is migrating from that.
That was the point of her first post, asking how to do that.
> Taking a step back and looking at it objectively, lets see, your
> design is properly SQL normalised and works fine now. You want to
> make it replicatable. The problem is you want to keep the
> CandidateID sequential in the replicated environment. Right?
She already knew the solution to part of the problem, which was
switching to a random Autonumber PK in the parent table in order to
make relationship enforcement easier.
> Option A: Add a new autonumber PK to every table.
Every table? Why?
Assuming there's only one table that needs a sequential number
viewable by the users before replication, surely only that table
used a non-Autonumber PK in the first place. The only option is
generating the sequence for every table.
But Penny did not say she was generating the sequential PK for
anything but a single table, tblCandidates.
So, I think you presumption that there's any need to add an
Autonumber PK to anything but the one table is mistaken.
> Work? Lots. Plus you also now have to create the table constraints
> in code. . . .
Eh? What table constraints are you talking about? Assuming that she
was using a generated sequential PK in all her tables (not just as
foreign key from a single parent table), an assumption that is
completely unwarranted based on Penny's original post, then
replacing those keys with an Autonumber adds no new constraints at
all, as you're replacing a code-generated key with an engine-created
random key.
There are no additional restraints on any other fields other than
what would have been there in a non-replicated environment.
> . . . Risks? High. Too many to list, and when do you update the
> front end for the new design? You have to kick the users out until
> your finished. . . .
Excuse me?
Doing this kind of update requires some planning. Any schema-related
update requires it.
First off, the front end should not be shared, so you won't have to
kick anybody out of the front end to make changes to the front end
required by changes in the schema.
Second, when the schema changes you need a new front end, replicated
or not. That means that it's best to roll out a pre-schema-change
front end that checks for evidence of the new schema having been
implemented, and if it finds it, tells the user that they must
upgrade to front end to the new version, and otherwise exits (that's
assuming the schema changes are incompatible with the old
application version). Or, if you're already using some for of
automatic update for the front end (such as Tony Toews auto
updater), all you have to do is coordinate the roll-out of the front
end with the synch between the production replica and the design
master.
Third, that would be the case regardless of whether or not the
application were replicated. The advantage to the replicated
scenario is that you can propagate the schema changes via a synch,
instead of having to use code or do them manually.
Fourth, rolling out schema changes of any kind, replicated or
unreplicated, requires kicking users out of the database.
> . . . Fix problem? No. Replica A can still create new
> records, incrementing the CandidateID number at the same time as
> Replica B. Therefore creating duplicates.
See above. These problems are by no means specific to replication --
they are all caused by changes to the schema.
> Option B: Leave the fields alone and create a design that allows
> only one replica to add records.
[quoted text clipped - 4 lines]
> users. Fix problem? Yes. The CandidateID is again guaranteed to be
> sequential.
There is still going to be downtime to the end users if you have any
schema changes to existing tables. If you want RI enforced in the
new tables that implement your independent solution, that can only
be implemented by kicking users out of the data file.
> Anyway, it's your choice and I hope it works out well for you. :)
I am really confused by the kinds of comments you are making here.
They seem to me to be very strange, and completely missing the point
of the original problem, despite my having pointed this out to you
several times.
Are you trying to confuse the matter here or are you trying to help?
From where I sit, it doesn't look like the latter.

Signature
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
David W. Fenton - 16 Jul 2005 02:23 GMT
> "You mean you don't use indexes in the table definitions to
> properly restrict entries in candidate keys that could have been
> the PK?" No. I use indexes in the fields that need them. I mean
> that due to the PK being a single autonumber field, if the true
> key is multi-column then I enforce the multi-column uniqueness in
> code.
Why? To me, that's risking your database because it depends on the
application to maintain data integrity. Data integrity should be
maintained by the database engine, as part of the schema definition
(including indexes).
> Actually you got me thinking. I just created three tables in a
> temp database. Two tables with multi-column PK fields and an
[quoted text clipped - 3 lines]
> the constraints coding. I shall give that good consideration in
> future Access databases. Thanks.
It would be what I consider to be standard practice.
Now, if you don't have a real candidate key that can be enforced by
an index, then, lacking triggers, you will need to use code to
enforce your definition of uniqueness. This is a very common
scenario in tables storing data on people, since applications often
have the requirement to be able to create a record for a person
without having the complete data that would be needed to insure
uniqueness in an index (i.e., fields in the candidate key need to
allow nulls, which means no unique index).
> ""> Option A: Add a new autonumber PK to every table.""
> "Every table? Why?...But Penny did not say she was generating the
[quoted text clipped - 3 lines]
> As per Penny's response "I am going with adding the Autonumber to
> all pertinent tables (which I will ALWAYS do in future)"
Well, I was surprised at that one. I don't know why anyone would use
a generated sequence for fields that aren't exposed to users, and in
most data hierarchies, the PK of the child tables just doesn't
matter. So, for replication, that means the random autonumber
doesn't cause a problem, and it also means that before replication,
there's no reason to program your sequence.
So, that's what confused me -- I couldn't imagine a scenario where
all tables other than the one she mentioned would have a generated
sequence. Yes, it's not uncommon to have a couple or three such
tables in an app, but certainly not *all* the tables.
To me, then, it looks like her original schema design was quite
unusual.
>> Work? Lots. Plus you also now have to create the table
>> constraints in code. . . .
[quoted text clipped - 3 lines]
> changes tables with multi-column keys, then yes this will be the
> case.
But not in *code*. Yes, she may end up with a useless generated
sequence if she doesn't change the code, but the "table constraints"
should not have been enforced in code in the first place, but in the
table and RI definitions.
>> . . . Risks? High. Too many to list, and when do you update the
>> front end for the new design? You have to kick the users out
[quoted text clipped - 4 lines]
> that need to take place in certain sequences and many places to
> make a mistake that can create headaches for Penny and the users.
But none of those steps are unique to a replicated back end -- all
of them apply in one degree or another to every database application
in which you are applying a schema update.
> "Are you trying to confuse the matter here or are you trying to
> help? From where I sit, it doesn't look like the latter."
>
> Oh well, I guess then that I hope to help Penny and confuse you.
> :) But at least your thinking and keeping me on my toes.
Well, I'm glad you answer questions in the group. Since MichKa has
moved on to internationalization, somebody has to keep the flame
alive.

Signature
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Cheval - 18 Jul 2005 22:37 GMT
MichKa, yeah? I was wondering why I haven't seen his postings for a while...
"Cheval" <NoSpam.Ask@ForEmail.com> wrote in
news:7_XBe.49658$oJ.14659@news-server.bigpond.net.au:
> "You mean you don't use indexes in the table definitions to
> properly restrict entries in candidate keys that could have been
> the PK?" No. I use indexes in the fields that need them. I mean
> that due to the PK being a single autonumber field, if the true
> key is multi-column then I enforce the multi-column uniqueness in
> code.
Why? To me, that's risking your database because it depends on the
application to maintain data integrity. Data integrity should be
maintained by the database engine, as part of the schema definition
(including indexes).
> Actually you got me thinking. I just created three tables in a
> temp database. Two tables with multi-column PK fields and an
[quoted text clipped - 3 lines]
> the constraints coding. I shall give that good consideration in
> future Access databases. Thanks.
It would be what I consider to be standard practice.
Now, if you don't have a real candidate key that can be enforced by
an index, then, lacking triggers, you will need to use code to
enforce your definition of uniqueness. This is a very common
scenario in tables storing data on people, since applications often
have the requirement to be able to create a record for a person
without having the complete data that would be needed to insure
uniqueness in an index (i.e., fields in the candidate key need to
allow nulls, which means no unique index).
> ""> Option A: Add a new autonumber PK to every table.""
> "Every table? Why?...But Penny did not say she was generating the
[quoted text clipped - 3 lines]
> As per Penny's response "I am going with adding the Autonumber to
> all pertinent tables (which I will ALWAYS do in future)"
Well, I was surprised at that one. I don't know why anyone would use
a generated sequence for fields that aren't exposed to users, and in
most data hierarchies, the PK of the child tables just doesn't
matter. So, for replication, that means the random autonumber
doesn't cause a problem, and it also means that before replication,
there's no reason to program your sequence.
So, that's what confused me -- I couldn't imagine a scenario where
all tables other than the one she mentioned would have a generated
sequence. Yes, it's not uncommon to have a couple or three such
tables in an app, but certainly not *all* the tables.
To me, then, it looks like her original schema design was quite
unusual.
>> Work? Lots. Plus you also now have to create the table
>> constraints in code. . . .
[quoted text clipped - 3 lines]
> changes tables with multi-column keys, then yes this will be the
> case.
But not in *code*. Yes, she may end up with a useless generated
sequence if she doesn't change the code, but the "table constraints"
should not have been enforced in code in the first place, but in the
table and RI definitions.
>> . . . Risks? High. Too many to list, and when do you update the
>> front end for the new design? You have to kick the users out
[quoted text clipped - 4 lines]
> that need to take place in certain sequences and many places to
> make a mistake that can create headaches for Penny and the users.
But none of those steps are unique to a replicated back end -- all
of them apply in one degree or another to every database application
in which you are applying a schema update.
> "Are you trying to confuse the matter here or are you trying to
> help? From where I sit, it doesn't look like the latter."
>
> Oh well, I guess then that I hope to help Penny and confuse you.
> :) But at least your thinking and keeping me on my toes.
Well, I'm glad you answer questions in the group. Since MichKa has
moved on to internationalization, somebody has to keep the flame
alive.

Signature
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc