I'm modelling articles and their authors, where each article can have multiple authors and each author can have multiple articles. It is important to keep the order of authors for a given article (being the 1st on the list of authors of a given article is very different from being the last author). How do I best keep the order of authors? (I am using postgres, 9.4)
The classical many-to-many via an intermediate table of "author_id, article_id" doesn't keep the order of authors for a given article. I see two solutions:
add an author_rank column to the author_articles table, making it "author_id, article_id, author_rank"
scrap the intermediate table, add an "author_ids" column in the article table and keep an array of author ids in there. (Losing automatic checks of referential integrity but gaining simplicity)
Any other solution? Any reason one of the two solution is much worse? Thanks!