... such that I can get the SUM(val) of rows where a_userID=1 and b_userID=2 and vice versa. This is at the top of a massive query that I don't want to run twice or group further, so my thought was to generate a partner key for 1+2 which would be the same key as for 2+1, but would be unique to just that combination of partners... I'm somehow tongue-tied trying to express this more clearly...
There must be some simple equation that can generate a unique number for any two number combinations ............right? Or is that a completely daft question? For some reason this has me stumped.
hey there. do you have any example of "simple equation" to compute unique number from two, even without f(x,y)=f(y,x) condition? I mean, you can fill your tables all you want as long as numbers' number is limited, but could it really be done for ALL the numbers?
I mean, if this kind of equation exists, it must be very weird, because every z = const plane would have to intersect z = f(x,y) in just one point (not a curve).
I think... if I didn't need f(x,y) == f(y,x), and assuming only positive integers where x != y, I could generate a unique number for each pair by doing (x*y)+y ...which gives a hyperbolic paraboloid.
However, that is dependent on the order f(x,y) and doesn't help my situation because I need a key by which to group both ways.
I've gone ahead and solved my problem by using CONCAT(MIN(userID),',',MAX(userID)) to generate a unique identifier, but unfortunately this is rather slow.
this gave me an idea... since I'm only looking at one quadrant, what if I took the radius of the circle needed to touch both (x,y) and (y,x)...I mean, just the hypotenuse of a right triangle touching either point... plus the sine times cosine of the vector... wouldn't that give a unique identifier?
(x^2+y^2)+( SIN(ATAN(x/y)) * COS(ATAN(x/y)) )
everything right of the decimal point would be descriptive of the vector, unique because of the phase difference and because we're only dealing with one quadrant... everything left of the decimal point would be a whole integer hypotenuse^2...
unfortunately no, it does not depend on how much of full plane you use, as long as there's infinite amount of numbers. take a look at the graph, and especially contour plot of your function below - every curve on contour plot represents a set of (x,y) points that evaluate in the same value.
yes... I know they're circular... but is there ever more than one pair of whole integers described? I mean, could any two integers produce the same result as any other two integers, so that
[ f(x1,y1) , f(y1,x1) ] == [ f(x2,y2) , f(y2,x2) ] ?
If not... then this would satisfy to give a unique identifier of two ID's combined...