In the US Navy, Captain (O6) is a pretty high rank, and is charge of major ships like aircraft carriers and cruisers, perhaps SSBNs .On other, smaller ships (destroyers, frigates, attack submarines), a commander (O5) is in charge. Really small ships and boats may be skippered by a officer of even lower rank.
(Admirals and commodores command groups of ships. An admiral typically commands from a flagship, which is typically large enough to merit a captain as commanding officer.)
In the first Aubrey Maturin book, Master and Commander, Jack Aubrey, a newly promoted commander, takes command of the fourteen gun HMS Sophie. He later becomes a Post Captain and is assigned various larger ships-- the most famous being the 28 gun HMS Suprise. I think Starfleet takes its cues from later navies, though. Otherwise, Picard would be a Yellow admiral by now!