Given a group $Q$ and an abelian group $C$, I want to determine the number $I(Q,C)$ of isomorphism classes of all groups $G$ having a central subgroup $C'$ isomorphic to $C$ such that the quotient $G/C'$ is isomorhic to $Q$. Thus $I(Q,C)$ equals the number of groups (up to isomorphism), that fit into a central extension 
$$ 1 \to C \to G \to Q \to 1$$
The number of such extensions (up to equivalence) is given by $|H^2(Q,C)|$ (trivial coefficients). This gives an upper bound. But often it is much larger than $I(Q,C)$ (cf. the example below). 


*Question:* Is it possible to obtain the correct value for $I(Q,C)$ out of $H^2(Q,C)$, or at least an improved upper bound ? 


*Example:* Let $C\_n$ denote the cyclic group of order $n$. Each $p$-group $G$ of order $n$ has a central subgroup $C\_p$. Hence $I(G/C\_p,C\_p)$ is the number of isomorphism classes of $p$-groups of order $n$. 


Take $n=2$. Then there are exactly two groups of order $p^2$, i.e $I(C\_p,C\_p) =2$, while 
$|H^2(C\_p,C\_p)| = |\mathbb{Z}/p\mathbb{Z}| = p$. From these $p$ extensions, $p-1$ belong to the isomorphism class of $C\_{p^2}$. 



Counting isomorphism classes via extensions 
Let $Q$ be a group and $A$ a $Q$-module. Call two extensions $G, G'$ of $Q$ by $A$ weakly equivalent, if there is a commutative diagramm 
$$ 0 \to A \to G \to Q \to 1 $$
$$ \hspace{2pt} \downarrow \hspace{20pt} \downarrow \hspace{20pt} \downarrow $$
$$ 0 \to A \to G' \to Q \to 1 $$
with vertical isomorphisms. Denote the corresponding set of equivalence classes by $W(Q,A)$. Since $G,G'$ are isomorphic, if the extensions are weakly equivalent, $W(Q,A)$ is finer than isomorphism classes, but coarser than $H^2(Q;A)$. 


In order to describe the relation between $W(Q,A)$ and $H^2(Q;A)$, some notation is needed: Call $(\varphi, \alpha) \in Aut(Q) \times Aut(A)$ compatible, if $\alpha(\varphi(q)\cdot a) = q \cdot \alpha(a)$ for all $q \in Q, a \in A$. Such a pair induces an automorphism $(\varphi,\alpha)^\*$ of $H^2(Q;A)$ (see Brown: Cohomology of Groups, III, after Cor. 8.2). 


Taking into account that cohomology is contravariant in the first argument, let $T\subseteq Aut(Q) \times Aut(A)$ be the subgroup of all pairs $(\varphi, \alpha)$ such that $(\varphi^{-1}, \alpha)$ is compatible. Then, $T$ operates on $H^2(Q;A)$ through $(\varphi,\alpha) \cdot x = (\varphi^{-1},\alpha)^\*(x)$. Now, the central result is: 



> 
> There is a bijection between $W(Q,A)$ and the orbits of $H^2(Q;A)$ under 
>  the action of $T$. 
> 
> 
> 


The proof consists in essential of the fact, that for a 2-cocycle $f: Q\times Q \to A$ 
and a compatible pair $(\varphi, \alpha)$, the extensions 
corresponding to $f$ and $f':= \alpha \circ f \circ (\varphi^{-1} \times \varphi^{-1})$ 
are weakly equivalent.


As noted above, weak equivalence is finer than isomorphism. But in some situations, $W(Q,A)$ will directly classify isomorphism classes. 



> 
> a) If the center of $Q$ is trivial, then $|W(Q,A)|=I(Q,A)$ (as defined in the question). 
> 
> 
> 


b) Suppose $A$ is finite and let the integer $k$ be coprime to $|A|$. Thus, multiplication by $k$ is an automorphism of $A$ that is compatible with $\operatorname{id}\_Q$. Hence, for $x \in H^2(Q;A)$, its orbit contains $kx$ for all $k$ comprime to $|A|$. In particular: 



> 
> If $|H^2(Q;A)|$ is a prime, then $|W(Q,A)| = 2$ and $I(Q,A) \le 2$. 
> 
> 
> 


Hence, in your example ahead, there are at most two isomorphism classes of groups of 
order $p^2$ and since $C\_p \times C\_p$, $C\_{p^2}$ aren't isomorphic, we are done. 


**Edit:** Including a proof of a) 


Let $\mathcal{C}$ be the class of groups $G$, satisfying $Z(G) \cong A$ and $G/Z(G) \cong Q$. By fixing such isomorphisms each $G \in \mathcal{C}$ exhibits a central extension 
$$\mathcal{E}\_G: \quad\quad A \cong Z(G) \hookrightarrow G \twoheadrightarrow G/Z(G) \cong Q.$$
The first key observation is: An isomorphism $\phi: G \to H$ maps $Z(G)$ isomorphically onto $Z(H)$ and therefore induces a commutative diagramm with vertical isomorphisms: 
$$\mathcal{E}\_G: \quad\quad A \cong Z(G) \hookrightarrow G \twoheadrightarrow G/Z(G) \cong Q$$
$$\hspace{17pt} \phi \downarrow \hspace{17pt} \phi \downarrow \hspace{17pt} \bar{\phi} \downarrow $$
$$\mathcal{E}\_H: \quad\quad A \cong Z(H) \hookrightarrow H \twoheadrightarrow H/Z(H) \cong Q$$
Hence $\mathcal{E}\_G$ and $\mathcal{E}\_H$ are weakly equivalent and we obtain a map 
$$\mathcal{C}/\cong \to \mathcal{W}(Q,A),\quad [G] \mapsto [\mathcal{E}\_G].$$
Since a weak equivalence between $\mathcal{E}\_G$ and $\mathcal{E}\_H$ implies $G \cong H$, this map is injective. Surjectivity follows from the second key observation: Let 
$$\mathcal{E}: \quad\quad A \hookrightarrow G \overset{\kappa}{\twoheadrightarrow} Q$$
be a central extension, i.e. $A \le Z(G)$. Since $\kappa$ is epi, $\kappa(Z(G)) \le Z(Q) = 1$, implying $Z(G) = A$. Thus $G \in \mathcal{C}$ and $[\mathcal{E}\_G] = [\mathcal{E}]$. 


