Normal force $F_N$ is just the force between two surfaces. It's called "normal" because it acts perpendicular (normal) to the surfaces.
Gravitational force is completely unrelated. Gravity always acts with $F_g = -mg$. The minus sign indicates that the force points down.
These two forces often oppose each other, which is why $F_N$ OFTEN, BUT NOT ALWAYS, $=mg$. The sum of all y-components of forces must equal acceleration in the y direction (Newton's 2nd Law). For a book resting on the table, there is no acceleration in the y direction, and 2 forces acting: gravitational force and the normal force. Since $a_y=0$, $F_N+F_g=0$, and $F_g=-mg$, so $F_N=mg$.
Hairy details and garlic for the higher-ups:
"Down" depends on your coordinate system. It's more accurate to express gravitational force as a vector (although you'll have to decompose it sooner or later).
$|F_g|=mg$ only near the surface of the earth. For a more general relationship, use Newton's Law of Universal Gravitation.
Newton's 2nd Law actually states that the vector sum of all forces is equal to the mass times the acceleration of the object: $\sum \vec{F}=m \vec{a}$. This is actually 3 scalar equations: $\sum F_x=ma_x$, $\sum F_y=ma_y$, and $\sum F_z=ma_z$.