If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > keeping integrity

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-05-04, 08:25
Rdean Rdean is offline
Registered User
 
Join Date: Nov 2003
Posts: 17
keeping integrity

Hi,

I have two tables that both contain integer fields that are to be used as unique identifiers. These tables, and fields, will only ever be updated manually. The issue I have is that a value assigned to one of these fields in one table cannot be assigned to the same field in the other. Thus, if 24 is assigned to this field in table A it cannot then be assigned to the same field in table B. Is there anyway to enforce this rule in DB2, without having to create additional lookup tables etc?

Thanks for any help

Richard
Reply With Quote
  #2 (permalink)  
Old 01-05-04, 08:53
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Re: keeping integrity

A SEQUENCE Object

http://www-106.ibm.com/developerwork...2fielding.html

http://www-106.ibm.com/developerwork...05pilaka2.html

Cheers
Sathyaram

Quote:
Originally posted by Rdean
Hi,

I have two tables that both contain integer fields that are to be used as unique identifiers. These tables, and fields, will only ever be updated manually. The issue I have is that a value assigned to one of these fields in one table cannot be assigned to the same field in the other. Thus, if 24 is assigned to this field in table A it cannot then be assigned to the same field in table B. Is there anyway to enforce this rule in DB2, without having to create additional lookup tables etc?

Thanks for any help

Richard
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.

Last edited by sathyaram_s; 01-05-04 at 08:55.
Reply With Quote
  #3 (permalink)  
Old 01-05-04, 10:30
Damian Ibbotson Damian Ibbotson is offline
Padawan
 
Join Date: Jun 2002
Location: UK
Posts: 525
Or maybe an identity column. Start one at 1, the other at 2 and increment both by 2 (so one table has even number id column and the other, odd).
Reply With Quote
  #4 (permalink)  
Old 01-05-04, 10:34
Rdean Rdean is offline
Registered User
 
Join Date: Nov 2003
Posts: 17
Thanks for the suggestions guys, but I think I am going to go with option C.... a subtle bit of database redesign

Thanks again!!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On