The defendant is charged with a crime by the arresting agency.
The District Attorney reviews the case and makes a decision whether or not to file charges.
If the District Attorney does not file charges, the case is dismissed.
If however, the District Attorney does file charges, there will be an arraignment where the defendant would plead either innocent or guilty.
If the defendant pleads guilty he/she would be sentenced and the case would be closed, if defendant pleads innocent then a court date would be set.
The court would then hear the case, reach a verdict, and the case would be closed.