Is it possible to generate a push notification (if the app is not in the foreground) on firebase db changes? I started coding an android app.
There certainly is. Just have your Android app write the notification request into the database.
Sending device-to-device notifications is not a supported scenario in Firebase Cloud Messaging (see this answer), so you'll need a server component for that. For an example of how to send a push notification in nodejs, see this answer.