on 2014 Sep 04 10:44 AM
We are using SQL Anywhere v12.01.3554.
What impact does changing primary key on a record have when done on remote side?
Here is our situation: 1. Record inserted into table.
INSERT INTO DBA.pi_count(company,brand,size,ticket,date_entered, time_entered,user_name,computed_cases) VALUES (30,0,0,176468,'2014-09-01 00:00','19:48:29.0','Dustyg',0)
The values for brand, size, computed cases are not known at time of insert. Primary key in this example is company, brand, size, ticket.
UPDATE DBA.pi_count SET brand=489 WHERE company=30 AND brand=0 AND size=0 AND ticket=176468
Size, computed cases is then updated. UPDATE DBA.pi_count SET size=346, computed_cases = 100 WHERE company=30 AND brand=489 AND size=0 AND ticket=176468
Data is then synchronized to consolidated database. What we end up with in consolidated is the record prior to update of 3 above.
This is not what I was expecting. Can anyone provide an explantion as to what is going on here?
I am guessing that my issue is updating the primary key and this is frowned upon in a MobiLink setup so I will likely need to re-design my table to avoid doing this in the future. This is the only table in our setup where we update the primary key after initial setup.
Thanks for any help.
Brian
Your expectation is correct, just have a look at these generell MobiLink development tips in the docs
MobiLink and primary keys
In a synchronization system, the primary key is the only way to identify the same row in different databases (remote and consolidated) and the only way to detect conflicts. Therefore, MobiLink applications must adhere to the following rules:
1. Every table that is to be synchronized must have a primary key.
2. Never update the values of primary keys in synchronized tables.
3. Primary keys in synchronized tables must be unique across all synchronized databases.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
...but it's for your own good, even if it doesn't feel like it at the time. 😉
Just to add:
I am guessing that my issue is updating the primary key and this is frowned upon in a MobiLink setup so I will likely need to re-design my table to avoid doing this in the future. This is the only table in our setup where we update the primary key after initial setup.
From MobiLink's point of view, a surrogate PK with no real meaning would certainly help to avoid the need to update a PK lateron. However, you state:
"Primary key in this example is company, brand, size, ticket."
So if there's a need that these values are unique (even when not used as PK and possibly not declared as UNIQUE KEYS) and will be filled lateron - how do you make sure no two remotes can set the same unique values for different rows?
I'm just hinting at the fact that modifying PKs in a ML setup is no good but guaranteeing non-PK UNIQUE constraints in a distributed system is not that easy, either... - it might require some kind of conflict resolution, methinks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
> guaranteeing non-PK UNIQUE constraints in a distributed system is not that easy, either
Indeed... it is the kind of thing that can cause an upload to fail, completely disabling further synchronization for the offending remote database. One workaround is to omit the UNIQUE constraint from the consolidated database. The real solution is to sit down and think carefully about the database design, away from distractions... it's not the job for a committee, the committee isn't there at 4AM when MobiLink stops working.
User | Count |
---|---|
66 | |
11 | |
10 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.