I'm trying to design the data schema and the restful api for a specific case.
In my system I have several users and several books. Every book can have several users as authors and at the same time every user can be an authors of several books.
Now the hard part, users are interested to have a list of their books and to let the system know they are the authors, but it's important that they can also keep this association private. So a user can be the author of a book but doesn't want to make this information public.
Now a first solution can be to replicate the books information for every author and set them as private or public but this is not what I want. My idea was to use two associations in the user entity (books, public_books) where the second one is a subset of the first one.
But another problem comes with the restful api. I'm not sure what is a good way to expose this kind of data.
Something like this maybe?
/users/:id/books
that returns a list of books made with an additional boolean property ispublic?
Is there a better idea to handle this situation in your opinion?
EDIT: The REST API needs to return all the books linked to the user and offer a way to distinguish between public and private books. A user can obviously see all his books, but only the public books of the other users.
Another necessary thing is the possibility for a user to change the status of one of his books. A private book can become public and viceversa.