MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 26th, 2004, 09:37 PM
uma_g uma_g is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 42 uma_g User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 37 m 7 sec
Reputation Power: 4
Question Primary Key Problem

hi

To make it more clear, i am explaining my problem in detail.

I am using two databases.One for online processing. Another database for offline processing. If new records are added in online database tables, then it should be added in offline database tables also and vice versa.

Suppose if a new user is added in USERS table in online database and userID 100 is assigned to that user.Similarly in Offline processing also, another different user is being assigned the same UserID 100. If i want to download/upload the database changes, there arises the primary key conflict, where in both databases there is a record with UserID as 100 and it is not possible to reassign userID.

how to solve this problem ??

Reply With Quote
  #2  
Old December 30th, 2004, 01:27 AM
iyad muhanna iyad muhanna is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 7 iyad muhanna User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Well, you need to make sure that userID is never the same in the 2 tables. Im guessing you have identity ON

One way to do this is to change the identity seed and increment.

Example:

In the first table USERS, set the seed = 1 and increment = 2
so the userID would be odds only (1, 3, 5, 7....)

In the second table USERS set the seed = 2 and increment = 2 (2, 4, 6, 8....) for evens

One odd and one even and increment by 2 no matter what seed you start at.

I Hope this helps.

Reply With Quote
  #3  
Old December 30th, 2004, 12:56 PM
Aforsythe Aforsythe is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 104 Aforsythe User rank is Private First Class (20 - 50 Reputation Level)Aforsythe User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 22 h 8 m 10 sec
Reputation Power: 4
I didn't think about that, this is a much better solution than the one I was going for in the other thread.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Primary Key Problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway