I need to construct such a polynomial, and more generally: given a group G, how can it be realized as a galois group?
closed as too localized by Steven Landsburg, Todd Trimble♦, Alex Bartel, JSE, Felipe Voloch Sep 10 '12 at 23:13This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. If this question can be reworded to fit the rules in the help center, please edit the question. 


For the case that $D_8$ is interpreted to be with $16$ elements (which is the case according to OP on M.SE) an example is given by $$ x^8  3 x^5  x^4 + 3x^3 +1 $$ This is a polynomial with minimal (in absolute value) discriminant with that Galois group. For the other interpretation of $D_8$ a polynomial with minimal discriminat would be $$x^4  x^3 x^2 +x +1 $$ As said in the comments the general problem is difficult (indeed open even regarding existence, that is over the rationals, which I assume is the intention of the question). The above polynomials and information are taken from the database of Jürgen Klüners and Gunter Malle where a great many examples and information can be found, presented in a nice way. So, for examples for specific not too large groups one migt well find a polynomial there, even if one wishes additional restrictions (on the siganture, say). 


Over $\Bbb Q$, F. Seidelmann, in "Die Gesamtheit der kubischen und biquadratischen Gleichungen mit Affekt bei beliebigen Rationalitätsbereich, Math. Ann. 78, 230233 (1917)", gives the following parametric representation of degree $4$ equations with group $D_8$: $$x^42(e^2f+g)x^24efx+[(e^2fg)^2f]=0$$ (with some restrictions on the parameters) 


For Galois groups up through degree eight, you can easily provide an infinte number of examples by the function field extensions listed here: 

