Both detective and crime scene investigator work together in solving the puzzle of a crime.
Detectives are police officers that have passed the detective exam. To become a CSI, you don’t necessarily have to be a police officer and pass an exam. However, there are many departments who train their police officers and detectives to be crime scene investigators, and vice versa depending heavily on geographic location and needs of an agency.
Crime scene investigators use scientific methods for preserving and processing the crime scene. In this way, detectives could focus on collecting information processed by the crime scene investigators which could be useful for them to apprehend the perpetrator of the crime, thus putting all the pieces together to solve a crime.
Thus, detectives and crime scene investigators fall under the criminal justice system umbrella, but are doing completely different work.