Skip to content

Conversation

@tas09009
Copy link
Contributor

@tas09009 tas09009 commented Jan 29, 2021

Somewhat related issue: #49

Problem

BookCategory was unable to display all data using the standard findbyID API and the reason being is that there was no unique identifier in the table. Both columns, book_id and category_id are foreign keys from other tables.

Fix

image

There is now a new column bookcategory_id, which will be a unique identifier (id) for each of the many-to-many relationships between books and categories so now, as you can see in the picture, book_id: 1 and book_id: 2 both belong in category: 1 and so on. The bookcategory_id isn't something we will actually use in an endpoint but at least it displays all the values. Before it wasn't able to do that.

In the end, I only created this API to be able to use inner join to query books and categories together. It's possible all of this could have been avoided by building a query on book itself but I think this may make it easier to tie in books, categories, and their respective relationships. This is also important to have if you want to see all relationships between books and categories.

Also @linesbetween, I have a lot of commented out code which I may end up using for later APIs but I wanted to leave it in for now and clean it all up later.

@linesbetween linesbetween self-requested a review January 29, 2021 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant