TITLE: Fibers of a scheme over $\text{Spec}\,\mathbb{Z}$
QUESTION [8 upvotes]: How to construct connected scheme $X$ over $\text{Spec}\,\mathbb{Z}$ such that for $p\neq0$ the fiber $X_p=X\times_{\text{Spec}\,\mathbb{Z}}k(p)$ over the prime ideal $(p)$ contains precisely $p$ points over $\mathbb{F}_p$? 
The same question for $p+1$ and $p-1$.

REPLY [6 votes]: Take the canonical morphism $X=\mathbb A^1_{\mathbb Z}=\operatorname {Spec} (\mathbb Z[T])\to \operatorname {Spec} \mathbb Z$, which has  fiber $\mathbb A^1_{\mathbb F_p}=\operatorname {Spec} (\mathbb F_p[T])$ over $(p)\in \mathbb Z$.
This fiber has exactly $p$ points rational over $\mathbb F_p$ .
Edit
The canonical morphism  $Y=\mathbb P^1_{\mathbb Z}=\operatorname {Proj} \mathbb Z[T,U]\to \operatorname {Spec} \mathbb Z$ has as fiber over $(p)\in \operatorname {Spec} \mathbb Z$ the projective line $\mathbb P^1_{\mathbb F_p}=\operatorname {Proj} \mathbb F_p[T,U]$, and that fiber has exactly $p+1$ points rational over $\mathbb F_p$-points.
This answers miguels's supplementary question in his comment.