Think of it like Naval uniforms for officers. Line officers are denoted with a star over their rank stripes. Line officers can do numerous tasks, but their main focus is command-oriented. Specialties (docs, some supply, chaplains, legal, etc.) have different uniform insignias over their rank stripes. Red shirts woud be like line officers. Because it never appears that you have enlisted on the bridge (unlike the USN), you would have either line officers or a specialty (science, engineering). The only other things redshirts get to do is die, and those are the enlisted.
So... an example of the structure of a military organisation i know:
├ Second in Command (Company)
├┼─Second in Command (Platoon)
└─┴─Second in command (Squad)
Each level of cause has a number of people they are in command over, but each "department" needs to have someone who is in command.
In star trek, it would be not unlike this. While there are major Departments under the captain of the ship, (Security, Sicence, Engeneering), each department has sub-departments (for Example Sicence has Stellar cartography, geo physics, astro physics and so on), that each has department heads.
Theese departments ultimately report to a subordenate command officer, who in turn reports to senior officers to ease the delivery of all important informations.
Basically theese dept. heads each take ALL the information from the department, filters out what is not nessacarily intersting for their superiour, and hand in reports.
Command staff also handles all the paperwork and duty assignments, or are in training to take on more important tasks (basically they are directly training for 2'nd or 1'st officer).
In the end, they are also the ones getting their heads ripped off when somthing goes wrong.