Kenneth Fisher shows how to use DB_NAME() and DB_ID():
I actually use them this way on a somewhat regular basis when I don’t want to have to tie back into sys.databases to just get the database name. And also in the WHERE clause when I want to restrict based on a database name.
It’s important to know where you are. Also, where your keys are.