Navigate
Home
ArticleWiki
Forum
Journal
Search
Newsletter
Links
Tech News
expertsrt.com
Welcome Guest.
Username:

Password:

Remember me

need help in resoving 2 many to one relationships
Welcome, Guest. Please login or register.
December 02, 2008, 09:18:03 AM
11304 Posts in 1248 Topics by 498 Members
Latest Member: katCheeme
Experts Round Table Network  |  Databases  |  MySQL  |  need help in resoving 2 many to one relationships « previous next »
Pages: [1]
Author Topic: need help in resoving 2 many to one relationships  (Read 410 times)
thepreacher

Offline Offline

Posts: 77


« on: September 23, 2007, 12:13:47 PM »

Problem,
A transaction has an ID and Will also cause many Withdrawal IDs ( for now i am limited to 12 but you may consider unlimited Withdrawal IDs)
the same transaction ID will also be linked to many withdrawal amounts also 12 for now)

The withdrawal code and transaction ID is needed to retrieve the Withdrawal amount.

I need help to design a table the helps to easily store and retrieve the data.

Would be grateful if an explanation is provided for any solution.

Thanks
Logged
VGR
Mentor

Offline Offline

Posts: 682



WWW
« Reply #1 on: September 24, 2007, 12:29:55 PM »

easy.

make that relatioship table :
create table transac_to_withdr(id_transaction integer not null,id_withdrawal integer not null,withdrawal float not null);

the two keys can not be unique
the withdrawal amount is an attribute to the relationship, thus it's a field in the relationship table
This said, I wonder why you need a withdrawal id in the relation, the withdrawal amount is enough for the moment unless you've more withdrawal attriobutes, of course. As set up, the table could as well be named transaction_amounts(id_transaction integer not null,withdrawal float not null);

regards
Logged

techie overlord, answers all kind of questions on http://www.europeanexperts.org
thepreacher

Offline Offline

Posts: 77


« Reply #2 on: September 24, 2007, 02:41:54 PM »

Thnks VGR for your help. Perhaps a  scenario will better explain my problem.

-----
A person transfers say $500. One of the effects of this transaction is that an ID is generated. However the person wants to withdraw this amount in 5 equal installments (ie 100 x 5). A business decision is to assign each of the installments an ID such that the person will have to supply their Transaction ID and Withdrawal(or Installment) ID before they can collect their cash. With each successful withdrawal, the used Withdrawal Id is flag as used and hence cannot be used again.


Transaction ID --->Withdrawal ID--->Withdrawal Amount
                               Withdrawal ID--->Withdrawal Amount
                               Withdrawal ID--->Withdrawal Amount
                               Withdrawal ID--->Withdrawal Amount
                               etc ....

Withdrawal Amount is the same for different Withdrawal IDs
-----
I hope this makes things a little clearer.


warmest regards
« Last Edit: September 24, 2007, 02:49:23 PM by thepreacher » Logged
Pages: [1]
« previous next »
    Jump to: