Operation that returns a unique result for each unordered set of numbers What operation $f$ can I apply to any two numbers $a$ & $b$, such that $$f(a,b) = f(b,a)$$
where $f(a,b)$ is unique for any combination of a & b in the set of whole numbers?
P.S. I'm really not sure what tag to use here, I'd appreciate someone adding the correct one.
A word on why:
I have a database table with two columns $a$ and $b$.
I'd like to ensure that there are no duplicate rows in my table.
However, I don't care about the order of $a$ and $b$.
a | b
--+--
1 | 2
2 | 1

Is effectively a duplicate.
 A: One could use
$$ f(a, b) = 2^{2a + 1} + 2^{2b + 1}. $$
It is easy to see that $f$ satisfies $f(a, b) = f(b, a)$.
Note that $2^{2x + 1} > 0$ for all $x \in \mathbb Z$ and also (letting $x = \max \{a, b\}$) we have 
$$2^{2x + 1} < f(a, b) \leq 2 \cdot 2^{2x + 1}.$$
To prove that $f$ has your uniqueness condition, we consider cases depending on two pairs $(a, b)$ and $(c, d)$ (where without loss of generality the first number in the pair is the larger one) of whole numbers:


*

*$a = c, b \neq d$ or $a \neq c, b = d$: Should be clear from the definition of $f$. 

*$a \neq c, b \neq d$. Then by symmetry (one could exchange the pairs) we may assume $a < c$ and hence 
$$
\begin{align*}
f(a, b)
&= 2^{2a + 1} + 2^{2b + 1} \\
&\leq 2 \cdot 2^{2a + 1} \\
&< 2^{2(a + 1) + 1} \\
&\leq 2^{2c + 1} \\
&\leq f(c, d).
\end{align*}
$$
In particular, this means $f(a, b) \neq f(c, d)$.


It follows that $f$ is a function satisfying your conditions :)
A: A possible solution can use the property that the set of rational numbers is countable. You can use a slightly modified pairing function to construct a function which satisfies the restrictions.
A: What you’re after is a function $f:\mathbb{N}^2\to \mathbb{N}$ that is injective in the half planes under and over $y=x$ and satisfies $f(a,b)=f(b,a)$. Since $\mathbb{N}^n$ is equipotent to $\mathbb{N}$ such a function exists and one takes usually defines $f$ as (supposing $a\leq b$):
$$f(a,b)=2^a3^b$$ and
$$f(b,a)=f(a,b)$$
