Route-finder / Backend

Senior Project - Find and display an optimal route to retrieve books from a library's shelves.
https://library-guide.herokuapp.com
Mozilla Public License 2.0
0 stars 3 forks source link

Primary Key Should Allow For Multiple Users to Have Same Book Stored #43

Closed Isaac-List closed 2 years ago

Isaac-List commented 2 years ago

Describe the bug With the new system including usernames in the booklist table in the database, the current Primary Key of just the ISBN number will prevent multiple users from saving the same book

To Reproduce Steps to reproduce the behavior:

  1. Add a book as one user
  2. "Sign in" with a different name
  3. Try to add the same book to the list with the new name
  4. See that this is unsuccessful

Expected behavior When a user attempts to add a book to their list that is not already associated with their username, they should be able to do so.

Additional context Note: users would still be unable to add the same book twice. This means that, when adding a book, we should first query the database to see if a book with that isbn and username is already stored, and if so return a helpful error message.

Isaac-List commented 2 years ago

Solution

Create a composite Primary Key which takes as its values the ISBN and the Username. Info on how to modify the database in this StackOverflow discussion.

Isaac-List commented 2 years ago

Altered the table, it now works.