# closed subschemes of projective space over a scheme

Let $X$ be an integral Noetherian scheme. If $Z \subset \mathbb{P}^n_{\mathbb{Z}}$ is a closed subscheme, under what conditions can we say that the codimension of $X \times Z \subset \mathbb{P}^n_X$ is equal to the codimension of $Z \subset \mathbb{P}^n_{\mathbb{Z}}$? I am really interested in the case that $Z$ has codimension one, i.e. $Z$ is a Weil divisor on $\mathbb{P}^n_{\mathbb{Z}}$.

Edit: this is not always true. If the subscheme is of an "arithmetic" nature, e.g. $\mathbb{P}^n_{\mathbb{F}_p} \subset \mathbb{P}^n_{\mathbb{Z}}$, then the result depends very much on the characteristic in which $X$ lives.

-

Exercise III.12.6 in Hartshorne says that $\mathrm{Pic}(X\times \mathbb{P}^n)\cong\mathrm{Pic}(X)\times\mathrm{Pic}(\mathbb{P}^n)$ if we assume $h^1(X,\mathcal{O}_X)=0$. Thus, if $\mathcal{J}$ is the ideal sheaf of $Z$, the ideal sheaf $\mathcal{O}_X\times\mathcal{J}$ corresponds to $X\times Z$, which means that its codimension is the same as the codimension of $Z$.