Key signatures determine the scale. In the key of C major, there are no sharps or flats that occur naturally but in other scales they do. Moving clockwise from C to G major, there is one sharp at the note F. Moving counterclockwise from C is F major and it has one flat at the note B. The next scales down on each side have two sharps or flats then three after that and so on.
Rather than putting a sharp by every F in a G major piece, we just put a sharp on the F line at the beginning so that the musician knows to sharp the F throughout. We call that the key signature. The relative minor uses the identical key signature as its relative major. All the available key signatures look thus:
Next, I'll show you how to assemble the correct key signatures using the circle of 5ths.