First, iCloud Photos is a synchronization service. When you engage iCloud Photos on a device, then the Library on that device is kept exactly the same as the iCloud Photos Library. So, for instance, if you take a picture with your iPhone, it is added to the iPhone's Photos Library, copied to iCloud Photos Library, and then copied to the Photos Library on each of the other devices that you have connected. If you delete a picture on your Mac, then that picture is deleted at iCloud and on all the other devices. So you can't think of iCloud Photos as a backup service, since it backs up mistakes, and there's no way to undo them. Whatever you do with Photos on your device-- it happens everywhere else.
Keeping your Mac Photos Library on an external drive is absolutely normal, and there's no reason that an external Library can't synchronize with iCloud and your other devices. Here is some info:
Move your Photos library to save space on your Mac - Apple Support
The above says that the external drive must be formatted in either APFS format or Mac OS Extended (Journaled) format. Additionally, the drive can not have had Time Machine on it since it was formatted. There have been so many problems with using incompatible drives that the newest macOSs won't even allow a Library on a non-Mac formatted drive to open, since there is a chance of damaging the Photos database.
There are three ways that using an external hard drive is different-- (1) For a laptop it's problematic to be plugging in and unplugging the Library while Photos is trying to use it (and this doesn't apply to you!) and (2) Spotlight won't find pictures in an external Library (but, of course, Photos' own search works fine.) and (3) For some crazy reason "gps location lookup" has problems. When you have GPS data (latitude and longitude) included with a picture, Photos goes to the internet and looks for the name of the place that's there-- but if the drive is external, this doesn't work. The GPS location is fine-- it just doesn't find the name. Any pictures that have already been looked up retain the name. I would think that this should be fixed sometime soon-- but not yet as far as I know.
A Mac can have multiple Libraries. I have a Library just for pictures from my Nikon. I edit and curate those, and I pick the best ones to put in my Favorites Library--the one that I have connected to iCloud. So only my favorite pictures are on my iPad and iPhone for me to look at and to share with friends and relatives. I also have Libraries for work pictures, for old family pictures, and for other special things-- favorites from these are also transferred to the Favorites Library.
If you have multiple Libraries, only one, the the System Library, can be connected to iCloud. The System Library is designated in Photos' Settings>General

Mine has "System Library" grayed out, because it is, already. A Library is connected to iCloud in Photos' Settings>iCloud

I don't use "Optimize" for Photos Libraries on my Mac, Optimize prevents making full local backups on Time Machine, etc. I do use "Optimize" on my iPhone.
Hmm-- I may have gotten carried away. Is this helpful?