All rings here are commutative rings with units, and $k$ is an algebraically closed field.
Definition: a ring $A$ is connected if it has only the trivial idempotent elements, i.e., if $e\in A$ satisfies $e^2 =e$, then $e=0$ or $e=1$.
Problem: Assumue $X$ is a nonempty affine algebraic set over $k$, then $X$ is connected (as topological subspace with Zariski topology) $\Leftrightarrow$ the coordinate ring $A(X):=k[x_1,...,x_n]/I(X)$ is connected (as a ring in the above definition).
My thoughts: "$\Rightarrow$": We can show that that an integral domain is connected. So if $X$ is an irreducible algebraic set, then $I(X)$ is a prime ideal and thus $A(X)$ is an integral domain, as a result $A(X)$ is connected. But I'm not sure about the case when $X$ is not irreducible, and how to apply the connectedness of $X$.
Background: I am a beginner at algebraic geometry. I've covered Hilbert Nullstellensatz and Noether normalization lemma so far.