If $f,g \in D[x,y]$ are algebraically dependent over $D$, then $f,g \in D[h]$ for some $h\in D[x,y]$? This question asks: If $f,g \in k[x,y]$ are two algebraically dependent polynomials over an arbitrary field $k$, is it true that there exists a polynomial $h \in k[x,y]$ such that $f,g \in k[h]$,
namely, $f=u(h)$ and $g=v(h)$ for some $u(t),v(t) \in k[t]$;
the answer is positive.

Is it possible to replace the field $k$ by an integral domain $D$?
  Namely: If $f,g \in D[x,y]$ are two algebraically dependent polynomials over an arbitrary integral domain $D$, is it true that there exists a polynomial $h \in D[x,y]$ such that $f,g \in D[h]$?

Denote the field of fractions of $D$ by $Q(D)$.
It is clear that if $f,g \in D[x,y] \subset Q(D)[x,y]$ are two algebraically dependent polynomials over $D$, then from the above question there exists a polynomial $h \in Q(D)[x,y]$ such that $f,g \in Q(D)[h]$,
namely, $f=u(h)$ and $g=v(h)$ for some $u(t),v(t) \in Q(D)[t]$.
I do not see why, for example, $D[x][y] \ni f=u(h)=u_mh^m+\cdots+u_1h+u_0$ should imply that $h \in D[x,y]$ and $u_j \in D$
(changing variables does not seem to help, namely if the leading term is $cy^l$,
with $c \in Q(D)$).
Any comments are welcome.
 A: No. Choose a field $k$ and $D=k[u^2,u^3,v^2,v^3,uv]\subset k[u,v]$, so $D$ is a noetherian domain. In $D[x,y]$, choose $f=(ux+vy)^2$ and $g=(ux+vy)^3$; they are clearly algebraically dependent (but $ux+vy\notin D[x,y]$). Write $K=k(u,v)=\mathrm{Frac}(D)$.

Claim: there is no $P\in D[x,y]$ such that $f,g\in D[P]$.

By contradiction, let $P\in D[x,y]$ such that $f,g\in D[P]$. So $f=r_1(P)$, $g=r_2(P)$ with $r_1,r_2\in D[t]$. Since $f^3=g^2$ and $K[t]$ is a UFD, there exists $r\in K[t]$ such that $r_1=r^2$ and $r_2=r^3$. So $r(P)^2=f$. So $r(P)=\pm (ux+vy)$; up to change $(u,v)$ to $(-u,-v)$, let us suppose $r(P)=ux+vy$. This implies that $r\in K[t]$ and $P\in K[x,y]$ have degree 1. Write $r=at+b$ and $P=cx+dy+e$; then $r(P)=acx+ady+ae+b=ux+vy$. So $ac=u$, $ad=v$, $ae+b=0$.
So $c,d$ are nonzero; then $c/d=u/v$, hence $cv=du$. Since $c,d\in k[u,v]$, we can write $c=uq$ and $d=vq$ with $q\in k[u,v]$. We have $aq=1$. Since $r^2\in D[t]$, we have $a^2\in D\subset k[u,v]$. So $a^2$ is invertible in $k[u,v]$, and hence $a\in k^*$. So $u=a^{-1}c\in D$, a contradiction.
