• Handling many to many relationships (corrections made)

    Posted on April 30th, 2008 biexplorer No comments

    (There were issues with the design in my original post. Those have been corrected. I have let the errors stay and have highlighted where I have made corrections so that you can understand better)

    Consider this situation.

    2 new guys Ravi and Raj go to our bank and open new savings accounts 101 and 102. And Ravi deposits 100 and Raj deposits 144. This can be represented by the following.

    CLICK ON THE IMAGES BELOW TO SEE A LARGER PICTURE

    Now suddenly, Ramu and Ramya come to the bank and open a joint account 103. And they deposit 1000. How will you represent this? What will you enter for CUST_KEY ? Will you enter 3 or 4? It was the same transaction of Rs 1000. But which customer to indicate? What will you fill in the red ? position below?

    To handle this, we can use a factless fact table or a bridge table. See picture below.

    (Though the pic below makes use of what looks like a factless fact table, it is an incorrect application. The best way is to use a bridge table.

    And the design below is not the right way to make use of a bridge table. The issue with this design is that for any info on the customer, you need to go through the Account dimension. Not a great design. Apologies for the poor design. See at the far bottom for the new design)

    Many to many 3

    The new design:

    Notice that there is a column called Weightage. This is to indicate the weightage of each customer in the joint account. In this case, I have taken both of them to be equal partners and hence the 50-50 % weightage.

    M2M

    Leave a reply

    You must be logged in to post a comment.