Re: Help in SQL to balance the values ... ?

From: Andreas Leitgeb <avl_at_gamma.logic.tuwien.ac.at>
Date: Mon, 24 Dec 2012 15:10:12 +0000 (UTC)
Message-ID: <slrnkdgs2k.u9l.avl_at_gamma.logic.tuwien.ac.at>



Nova <nova1427_at_gmail.com> wrote:
> I make easier example and I draw it in a paper
> give in info as following:
> in table F_LINKTO_M
> F M
> ----------
> F1 M1
> F2 M1
> F2 M2
>
> in table F_V
> F F_V
> ----------
> F1 100
> F2 70
>
>
> in table M_V
> M M_V
> ----------
> M1 150
> M2 45
>
> In conclusion (Final Result)
> F1 = 0 remaining
> F2 = 0 remaining
> M1 = 0 empty
> M2 = 15 empty

The drawing indeed helped to some degree.

I'm wondering, if for the given example
  F1 = 0, F2 = 0, M1 = 15, M2 = 0
would be a solution, too (as in F2 dumping to M2 first, and only the remainder to M1).

Also, if for some reason, F2 paired with M1 first (before F1 does), then the result would become F1 = 20, M1 = 0, F2 = 0, M2 = 45 with no chance for F1 to dump its remaining 20 .

So, I think, what you're really after is finding an arrangement that would get all Fs to 0. But that is an entirely non-trivial thing (maybe even NP-complete). Received on Mon Dec 24 2012 - 16:10:12 CET

Original text of this message