Answer to Question 1
Grating is a piece of glass with thousands of microscopic parallel lines scribed onto its surface. Different wavelengths of light reflect from the grating at slightly different angles, so white light is spread into a spectrum and can be recorded, often by a charge-coupled device (CCD) camera. Recording the spectrum of a faint star or galaxy can require a long time exposure, so astronomers have developed multiobject spectrographs that can record the spectra of as many as 100 objects simultaneously. Multiobject spectrographs automated by computers have made large surveys of many thousands of stars or galaxies possible.
Answer to Question 2
To analyze light in detail, you need to spread the light out according to wavelength into a spectrum, a task performed by a spectrograph. You can understand how this works by reproducing an experiment performed by Isaac Newton in 1666. Boring a hole in his window shutter, Newton admitted a thin beam of sunlight into his darkened bedroom. When he placed a prism in the beam, the sunlight spread into a beautiful spectrum on the far wall. From this and similar experiments, Newton concluded that white light was made of a mixture of all the colors.