making groups in database