Write affiliates to DB