How to set a parent from one-to-many relationship?
You could use a CASE an correlated subqueries.

In the subquery select the minimum id for the row's unified_id.

If the row's id is equal to this minimum, parent is null, making the article a parent. If it isn't equal to the minimum it's a child of the article with the minimum id. Set the minimum id as parent then.

INSERT INTO articles
            (id,
             parent_id)
            SELECT amo.id id,
                   CASE
                     WHEN amo.id = (SELECT min(ami.id)
                                           FROM article_map ami
                                           WHERE ami.unified_id = amo.unified_id)
                       THEN null
                     ELSE
                       (SELECT min(ami.id)
                               FROM article_map ami
                               WHERE ami.unified_id = amo.unified_id)
                   END parent
                   FROM article_map amo;


Or you can use a union. First select all parents using the minimum and a GROUP BY unified_id. Unify that with an INNER JOIN of article_map an the parents.

INSERT INTO articles
       SELECT min(am.id) id,
              null
              FROM article_map am
              GROUP BY am.unified_id
       UNION ALL
       SELECT amo.id id,
              p.id parent
              FROM article_map amo
                   INNER JOIN (SELECT min(ami.id) id,
                                      ami.unified_id
                                      FROM article_map ami
                                      GROUP BY ami.unified_id) p
                              ON p.unified_id = amo.unified_id
                                 AND p.id &lt;&gt; amo.id;


(Minimum and maximum (and possibly others) are interchangeable here of course.)