Let $X$ be a finite multisubset of $\mathbb{N}^2$. Let's introduce the following notation:
$A$ is a set of all first elements of pairs from $X$ and $B$ is a set of all second elements of pairs from $X$.
$cnt_1(n) = |\{(n, b)|(n, b) \in X\}|$ (that is a number of elements in a corresponding set).
$cnt_2(n) = |\{(a, n)|(a, n) \in X\}|$
$sum_1(n) = \sum_{(n,b) \in X}b$
$sum_2(n) = \sum_{(a,n) \in X}a$
$Y=\{(a, cnt_1(a), sum_1(a))|a \in A\}$
$Z=\{(b, cnt_2(b), sum_2(b))|b \in B\}$
The question: Given only $Y$ and $Z$ is it always possible to unambiguously reconstruct $X$?
Equivalently, phrased in terms of SQL: Given an (unordered) set of 2-tuples (X
) of natural numbers:
CREATE TABLE X (
a int,
b int
);
the following statistical summaries and are derived:
Y
:
SELECT a, COUNT(1) AS ca, SUM(b) AS bs FROM X GROUP BY a ORDER BY a;
Z
:
SELECT b, COUNT(1) AS cb, SUM(a) AS as FROM X GROUP BY b ORDER BY b;
Is it possible to unambiguously re-construct X
when knowing only Y
and Z
?