TITLE: A combinatorial identity.
QUESTION [5 upvotes]: Let $n \in \mathbb N$ and $X_1,\ldots,X_n$ be subsets of $\{1,\ldots,n\}$ such that there is some $p$ such that $\forall i\in  \{1,\ldots,n\}, |X_i|=p$.
Suppose as well that there is some $q$ such that  $i\neq j \implies |X_i \cap X_j|=q$.
Prove that $p^2=p+(n-1)q$.

I tried something with an incidence matrix and it boils down to proving that its determinant is $p^2(p-q)^{(n-1)/2}$, but I can't prove that
EDIT: The problem as it is stated is flawed. It must be added that each $i$ appears in exactly $p$ of the $X_j$

REPLY [2 votes]: I prove $p^2 \le p+(n-1)q$ in general and the equality holds if and only if @user133281's assumption is true:
Define a matrix $A =(a_{ij})$ where $a_{ij} = 1$ if $j \in X_i$ and otherwise $a_{ij} = 0$, then the given condition can be written as 
$$AA^{T} =  \left( \begin{array}{ccc}
p & q & \cdots & \cdots &q \\
q & p & q & \cdots & q  \\
\vdots & \vdots & \vdots & & \vdots \\
q & q & q & \cdots & p \end{array} \right) $$
Denote $b_i = \sharp\{j, i\in X_j\}$, then by multiplying both sides of the above matrix identity by the vector $v = (1,1,1,\cdots, 1)^T$ and computing the elements' sum of both results, we can show $$\sum_{i=1}^n b_i^2 = n(p+(n-1)q)$$
(Remark that $A^T v = (b_1, b_2, \cdots, b_n)^T$ and the elements of $A(b_1, b_2, \cdots, b_n)^T$ sums up to $\sum_{i=1}^n b_i^2$)
And obviously we also have $\sum_{i=1}^n b_i = np$. 
Since $(\sum_{i=1}^n b_i^2 )(n) \ge (\sum_{i=1}^n b_i )^2$, we have $ n^2(p+(n-1)q) \geq n^2p^2$, so $p^2 = p+(n-1)q$ if and only if all $b_i$'s are equal, i.e. $b_i = p, \forall i$