DEV Community

Discussion on: How to structure API for creating content with parent/child relationship?

Collapse
 
kspeakman profile image
Kasey Speakman • Edited

Forgive me -- the linked post is not a direct answer, but I think gets at the heart of the issue.

Things that happen in relationships are the things that matter.

Following the advice there, I would say that the relationship between the article and the publication is an entity itself. If your REST API represents essentially database calls, then it would be two operations: one on article and one on the article-to-publication link entity.

Edit: I suppose with this answer I was also assuming something different than the title. That it is potentially a many-to-many relationship between article and publication. If it is a 1-to-many relationship from publication to article, then it seems fair that article could be a sub-entity of publication.