I am a bit confused about variable elimination in a Bayes Network. For example, in the following Bayes network, if I want to get P(D|B), can I directly eliminate E, F and G since they are irrelevant? So that I don't have to join them to get factors?

I am a bit confused about variable elimination in a Bayes Network. For example, in the following Bayes network, if I want to get P(D|B), can I directly eliminate E, F and G since they are irrelevant? So that I don't have to join them to get factors?

Copyright © 2021 JogjaFile Inc.
Yes. You do not need to factorise the decendents of D, since they will sum to unity by the law of total probability.
Let us do it anyway to show this.
$$\begin{align}\mathsf P(\mathrm D\mid\mathrm B)&=\sum_{A,C,E,F,G}\mathsf P(A)\,\mathsf P(C\mid A,\mathrm B)\,\mathsf P(\mathrm D\mid C)\,\mathsf P(E\mid\mathrm D)\,\mathsf P(F\mid\mathrm D)\,\mathsf P(G\mid F)\\&=\sum_{A}\mathsf P(A)\,\sum_C\mathsf P(C\mid A,\mathrm B)\,\mathsf P(\mathrm D\mid C)\,\sum_E\mathsf P(E\mid\mathrm D)\,\sum_F\mathsf P(F\mid\mathrm D)\,\sum_G\mathsf P(G\mid F)\\&=\sum_{A}\mathsf P(A)\,\sum_C\mathsf P(C\mid A,\mathrm B)\,\mathsf P(\mathrm D\mid C)\,\sum_E\mathsf P(E\mid\mathrm D)\,\sum_F\mathsf P(F\mid\mathrm D)\cdot 1\\&=\sum_{A}\mathsf P(A)\,\sum_C\mathsf P(C\mid A,\mathrm B)\,\mathsf P(\mathrm D\mid C)\,\sum_E\mathsf P(E\mid\mathrm D)\cdot 1\\&=\sum_{A}\mathsf P(A)\,\sum_C\mathsf P(C\mid A,\mathrm B)\,\mathsf P(\mathrm D\mid C)\cdot 1\end{align}$$