Modeling Entities

 I have this  Entities. Article and Author. Each Article can have a few Authors and a few CoAuthors. CoAuthors are also records of Authors entity. I want to make a another entity model which connect article to the authors. I tried this way, But it does not really help, because I need to check that Author will be added on each article as an author or CoAuthor and not give a chance two be both. How can I model my entity? I am a bit lost

Hi Nino,

You could have only one entity ArticleContributor, with a unique index on ArticleId + ContributorId.

Then add a type or flag as attribute to this entity that serves to distinguish Authors from CoAuthors.

I would personally prefer to do this by adding a reference attribute to a static entity ContributorRole with 2 roles Author and CoAuthor, this is easily extensible to other roles like Publicist.  But you could keep it simple by just having a boolean IsMainAuthor or something.

Dorine

I 100% agree with Dorine solution. But I reinforce the idea of the static entity in order to extend to other roles: Translator, Editor, etc.


Regards

Thanx @Alberto Ferreira for the enforcement of the static entity idea šŸ‘

But now revisiting this post, I mentioned a unique index on book + contributor because that was explicit ask in the post, but in the real world, people can of course contribute to a book in more than 1 way, so unique should probably be book + contributor + role

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.