Click to See Complete Forum and Search --> : Common problem in my DataBase design !


the_knight5000
June 22nd, 2009, 11:39 PM
Hello all,

this is a common problem in all my database design ,

let's say I have a three types of Clients... ClientA , ClientB and ClientC ... Completely different in their properties ! .. so I stored them in three different tables !!

So , I have a Safe and SafeTransactions ... in SafeTransaction I put fields like {trnID , trnClientID, trnValue, trnIn, trnDate ..... } , and stopped here !!!

How can I retrive the client from the transaction !! what's the modification I need ?!

thanks in advance

davide++
June 23rd, 2009, 06:41 AM
Hi all.

Well, the statement "I have three type of clients completely different" sounds a bit strange for me; after all, a customer is a person, and for all db I've seen the table CUSTOMERS has more or less the same information, such as an ID, the name, address, phone numbers and so on.

Anyway, you have three tables and you want to set a relationship with another table. You have two choices.
1. Put three fields in SafeTransaction, let say trnClientID_A, trnClientID_B, trnClientID_C, and set the relationship with the Clients' table; the fields will be nullable, and only one will contain a value, so you can know what is the client that is referred.
2. Put two fields in SafeTransaction, let say trnClientID an trnClientType, both mandatory. trnClientID will contain an ID client, and trnClientType will contain a value (for exampe A, or B, or C) that says what is the table linked by trnClientID value.

Personally I prefer the second solution.

I hope this will help you.

the_knight5000
June 23rd, 2009, 10:40 AM
really thanks for ur help,

actually I see the second solution is fine because it is more scalable , but ...


that means I should use "if " or "Switch" in my code , isn't it ?
I don't like to make it cases !! , I'm fighting for an abstract design of my code !!

Any suggestions, any hope !!

thanks again !

the_knight5000
June 24th, 2009, 01:49 PM
any help !