This work mainly includes two parts: the theoretical predictions and observational results on the correlation of SFR and gas-phase metallicity Z gas . We first predict the correlation between SFR, cold gas mass and Z gas in the gas-regulator frame that the instantaneous SFR is regulated by the interplay between inflow, outflow and star formation. The mean SFR is determined by mean inflow rate and mass-loading factor λ, while the mean Z gas is determined by the metallicity of inflow gas Z 0 and the effective yield (y eff ≡ y/(1 + λ)). The SFR and Z gas relative to their mean values, denoted as ∆SFR and ∆Z gas , are found to be negatively (or positively) correlated when driving the gas-regulator with time-varying inflow rate (or SFE). We then study the correlation of ∆sSFR and ∆Z gas (defined in a similar way as in the model) from the observation, at both ∼100 pc scale and galactic scale based on two 2-dimensional spectroscopic surveys with different spatial resolutions, MAD and MaNGA. The metallicity increases strongly with global stellar mass across galaxy population, and decreases with galactic radius within individual galaxies, which can be interpreted as the mass and radial dependence of Z 0 and y eff . After taking out the mass and radial dependence, we find that ∆sSFR and ∆Z gas are found to be, negatively correlated at galactic or sub-galactic scale across galaxy population, and positively correlated at ∼100 pc scale within galaxies. This strongly supports the conclusion that the star formation is primarily driven by the time-varying inflow at galactic scale, and driven by the time-varying SFE at ∼100 pc scale. Furthermore, at sub-galactic scale, the variation of ∆sSFR and ∆Z gas as a function of gas depletion time are well matched with the model predications of time-varying inflow rate, strongly strengthening our conclusion. We build a comprehensive frame to understand the correlation between SFR, cold gas mass and metallicity, as well as the variability of them, which potentially uncovers the relevant physical processes of star formation at different scales.