Speaking broadly of the TNG era and of that show in particular, I'm good with that... I think that for the Golds and Reds, rank is commensurate with position. Loosely, on a big ol' flagship crewed by Starfleet's best and brightest, the Captain is the only one of that rank, and basically all the major department heads are Lieutenant Commander even if in general that position ought to be held by a Lieutenant, tops. An XO will need quick authority over them, so he gets to be a full Commander.
Other starship XOs in the TNG era are typically a Lt. Cmdr.; I see this as being that in general, these are lesser ships or posts and whose underlings are correspondingly of lower rank (i.e. whose department heads are Lieutenants or lower). Unless your command posting is already filled with more senior department heads, FULL commanders end up in charge of installations (Quinteros, Sisko), and you could make an argument that you can get bumped up a grade if your job expands in its scope (Sisko).
Regarding the blue shirts, in the sciences you'd likely work your way up like everyone else, to a maximum department head rank of Lieutenant Commander (La Forge in Engineering, Darren in Stellar Cartography, etc.) or potentially commander if your expertise warrants having authority over your peers for that assignment. In Medical, you'd have a rank depending on the needed authority, which is why Bashir ended up a Lieutenant and in charge of a medical department, while Ogawa was an Ensign forever and eventually got promoted to a still-lesser position within a larger department. Crusher would already hold medical authority over everyone anyway, but in order to have command authority on the ENTERPRISE, she'd have to be above the typical blue Lieutenant Commander and as such would have been bumped to the full bird rank. Heck, perhaps she was at the lower rank prior to coming aboard, and only upon accepting the position did she realize that she'd get a promotion.
Which bring us to Troi, who'd be in the position of needing to be the head of the counseling department, which would be a Lieutenant Commander for a big important ship like the Enterprise; or in combination with her additional responsibilities on the bridge as exposition provider. Then similarly, in order to be a bridge officer on top of that, she'd need to have a promotion to reflect the needed authority for someone in her position. As Timo said, it could be a matter of points, in combination for a sideways-method for non-command or operations officers to have that needed command authority for their posting.
Mark