-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Composite key columns referenced from two different tables
PostPosted: Fri May 21, 2004 12:28 pm 
Beginner
Beginner

Joined: Fri Apr 02, 2004 1:20 pm
Posts: 23
I have a very odd relationship in part of a legacy schema, was just wondering if anyone can see a way to map it directly.

Contract is 1 <-> 1 with BillingDetails (FK [ContractNumber])
Contract is 1 <-> 1 with Payer ClientRole (FK: [ContractNumber, 'PY'])
Contract is 1 <-> 1 with Mandate (FK: [BillingDetails.MandRef, Payer ClientRole.ClientNumber])

That is to say, Mandate has a composite key, and the values required to index into that composite key come from two different tables.

Sample SQL to retrieve the mandate details for a Contract would be:

SELECT
mand.bankkey,
mand.bankacckey
FROM
chdrpf chdr,
payrpf payr,
clrrpf clrr,
mandpf mand
WHERE
chdr.chdrnum = ? AND
payr.chdrnum = chdr.chdrnum AND
clrr.forenum = (rpad(chdr.chdrnum, 8) || '1') AND
clrr.clrrrole = 'PY' AND
mand.payrnum = clrr.clntnum AND
mand.mandref = payr.mandref


I think I'm going to have to define a view for this, but I'd be interested to see if anyone sees another way!

Thanks

Niall


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.