In the context of Krull dimension, given any commutative ring $R$ and $\mathfrak{p}\subset R$ a prime ideal, we have (almost by definition) $$ \mathrm{ht}\:\mathfrak{p}+\mathrm{coht}\:\mathfrak{p} \leq \dim R $$ In the special circumstance of the coordinate ring of an (irreducible) affine variety, i.e. $R$ being a finitely generated $K$-algebra which is an integral domain we have the equality $$ \mathrm{ht}\:\mathfrak{p}+\mathrm{coht}\:\mathfrak{p} = \dim R\quad (*) $$
I was curious on when (which type of rings) this equality $(*)$ happens? By the way, does this equality/inequality have a name?
First of all seems like we better assume $\dim R<\infty$ for preventing things to go haywire. Then if $\mathfrak{p}_0\subsetneq\cdots\subsetneq \mathfrak{p}_m=\mathfrak{p}$ is a chain the length of which is $\mathrm{ht} \: \mathfrak{p}$ and $\mathfrak{p}\subsetneq\cdots\subsetneq \mathfrak{p}_n=\mathfrak{m}$ a chain the length of which is $\mathrm{coht}\: \mathfrak{p}$, then defining $n$ as the length of the two chains combined: $$n\leq \mathrm{ht}\:\mathfrak{m}\leq \dim R.$$ So we have two inequalities we need to satisfy. The second inequality can be satisfied by assuming $R$ is equicodimensional, i.e. $\operatorname{ht}\mathfrak{m}=\dim R$ for any maximal ideal $\mathfrak m$.
The first one is trickier. It is happening because it is possible to have another maximal chain of primes inside $\mathfrak{m}$ which doesn't pass through $\mathfrak{p}$ and its length is bigger than $n$. I know of one way to make this imposible (which may not be the most general condition):
Fact: If $R$ is a equicodimensional Cohen-Macaulay ring then every maximal chain of prime ideals is of the same length $\dim R$.
So what I have come up with is if $R$ is a equicodimensional CM-ring then the equality (*) holds (right?).
How much further can one go in stating the most general condition for the onset of equality $(*)$? Is it even useful to go further?