There can be many different kinds/strains of bacteria, but they are all anxic, use the O in the no3 and covert it into nitrogen gas.
There is some nuance that you must understand... and I will try and keep this short:
They work best in concert with different critters creating pathways in each medium and the rock being stable if the sand gets disturbed, and vice versa, but one can work without the other. Sand has more ability to lower no3 than rock does - I use about 3 inches works great for denitrification and I don't see the need to use 6 inches which was popular many decades ago. Man made rock does not act like aragonite and is mostly more like a decoration, so treat it like a sunken pirate ship or a skull.
If using dead or dry rock, it can take a few years before that rock can house a stable and effective anoxic bacteria population since the bound terrestrial phosphate and organic gunk creates a bad environment down into the pores that takes years to work out from the surface going inward. A new sandbed can be decent in a few months and really good in 9 months. The sand does need vacuumed over the years to remove detritus which, while benign/void of any nitrogen or phosphorous, can gum up the works and not allow the processes to work well - I vacuum out mine about every 4 years but only do 20-25% at a time and wait a few months in between.
The aragonite sand and rock will also bind phosphate - it is just what it does in Chemistry 101 style. It can bind a lot and hide a husbandry problem with lack of export (fuge, skimming, etc.). Eventually it will fill up and the phosphate level will rise significantly in the tank. People used to call sand beds "time bombs" because of this, but the sand was not the problem, the lack of understanding and poor maintenance from the idiot keeper was the issue... along with message board parroters who latched on to the term time bomb and had no idea what they were saying. You need to watch your P level and still export so that the sand is a buffer and not a reservoir. I use chaeto, heavy skimming to keep my P about 1-3 ppb and I have no worries about it getting to growth limiting levels since the sand will release some if it gets too low (great buffer).
Both sand and rock can be used indefinitely and while they can make routine maintenance next to nothing, they still take some work in the long term. Make sense?