It depends pretty much on what you define as a book. Are part 1 and part 2 of the same book one or two books? If there are 20 parts, is it one or 20 books?
And if they are one book, can the different parts be placed on more than one shelf?
If the answer to the last question is yes then you need a table between and use a composite key. That will enable you to place one book on more than one shelf.
If the answer is no the best way to solve it is to add shelf_id as a foreign key in book. Note that it's no good idea to use a composite key, if you do then you will not have the possibility to move a book without removing the book from the database and add it again.