How to store device(Sonoff,s) status in database using node-red?

I want to store device's status e.g
which device connected to mqtt or which device is sending signals(ON,OFF) to mqtt.

What sort of database?
Have a look in flows.nodered.org to see what is available for the database type you want to use.

@Colin i have to store device's ID and Status in database in node-red.
I know node-red support databases e.g MsSql .
But how to integrate it with the sonoffs?

I install mosquitto on my pi and then use OpenHab in the Sonoff 'Controlers' Protocol.
If you look at the thread Coffee pot timer you will see how I set the controler on a SonOff S20 switch. That and the flow should get you pointed in the right direction.

Do you already have the Sonoff's sending data to MQTT? If so then you can use the MQTT In node to get the values into node-red.