Record connected components in the database