# How should I use stochastic gradient descent when I have two sets of data?

In social recommender system problems, we have two sets of data, one the rating data denoted as $R$ and the other social data denoted as $T$, most of the papers end at an objective function over these two sets of data, something like this:

$$\text{Minimize} J = \lvert \lvert R - U^TV \rvert \rvert^2 + \beta ||T - U^TZ|| + \lambda(||U||^2 + ||V||^2 + ||Z||^2)$$ Where the first term is for rating data $R$ and the second term is for social data $T$

I have came up with the following code for training, can anyone tell me if I am doing wrong? or should I alternate between social data and rating data and update parameters in that way?

def iterate():
for (u, i) in rating:
// the gradient term is computed by the first term of objective function and regularization part
// update U,
// update V,
for (u, v) in social_data:
// the gradient term is computed by the second term of objective function and regularization part
// update U
// update Z