Chain of Command

Far as I recall – CO, XO, 2nd, Department heads are all senior staff, followed then by ranking staff.

This creates the craziness of ensigns in flight controller or operations manager roles being considered senior staff over lieutenants that presumably had previously held such posts. That’s not to say we don’t see such things in the shows, and even other weirder examples like an NCO holding a department head position on DS9.