That's exactly the idea. Theoretically, the beta is the multiplicative coefficient found in the linear regression of the stock returns on the market (index) returns. The formula is the covariance of the two return histories divided by the variance of the market returns.
Hope this helps.