The first approach might work. It is a standard DOM feature, which of course is supported in ManifestV3 extensions. The only difference (that is not important for your use case) is that service worker cannot create an iframe, a workaround for that is the chrome.offscreen API when it's enabled in stable Chrome.
The second thing does not apply to extensions because they don't have domains.
Another possibility is to make the actual requests to the DB in the background script, whereas the content script will only provide an interface.
There may be other solutions depending on what specifically you want to do.