how to generate unique keys for the same customer?

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
natashab
Participant
Posts: 17
Joined: Mon Aug 09, 2010 3:44 am

how to generate unique keys for the same customer?

Post by natashab »

In Banking Domain,a new customer deposits some amount say Rs.5000.The same day the customer withdraws Rs.1000.Will the customer be generated with 2 different surrogate keys generating duplicate records if the target table is used as Reference table while performing a lookup?
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Post by kris007 »

The Answer depends. Are you storing the deposit and withdrawal information in the same table? If yes, there should another column that should be part of the key on that table that defines if the transaction(record) is a deposit or withdrawal. You should not be creating different Surrogate Keys for the same customer.
Kris

Where's the "Any" key?-Homer Simpson
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

That's completely up to you, your requirements and your job design, it seems to me.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

I will say that the customer being a single entity will always have a single live surrogate key.

Your transactions will not impact these in any way.
natashab
Participant
Posts: 17
Joined: Mon Aug 09, 2010 3:44 am

Post by natashab »

The sequence runs once everyday.Then will not the same customer having 2 incoming records with the amount deposited and amount withdrawn details be looked up and considered as 2 new records?If so, how to generate unique records for the same customer?
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Post by kris007 »

natashab wrote:Then will not the same customer having 2 incoming records with the amount deposited and amount withdrawn details be looked up and considered as 2 new records?
No. The record will/should be treated as an update record. Again that depends on the data model you have.
Kris

Where's the "Any" key?-Homer Simpson
HariK
Participant
Posts: 68
Joined: Thu May 17, 2007 1:50 am

Post by HariK »

Yes, the customer would be treated as two different persons unless you have set the commit size to 1 and using sparse lookup.

just wondering why not remove duplicates on customer before doing the lookup.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Are you populating the transaction or customer master ?

If it is transaction, you will have 2 entries - one for each transaction.

For customer master, you can try including a 'remove duplicates' to obtain distinct list. Also reference to existing customer master will ensure retaining keys for old ones.
siauchun84
Participant
Posts: 63
Joined: Mon Oct 20, 2008 12:01 am
Location: Malaysia

Post by siauchun84 »

How do you know that was same customer? From which point that you define it as same customer? Then you might able to come out the unique key for that particular customer.
Post Reply