books-api icon indicating copy to clipboard operation
books-api copied to clipboard

Add series

Open knjk04 opened this issue 5 years ago • 17 comments

If a book is in a series, it should be possible to see:

  1. Its position in the series
  2. The name of the series (e.g. 'Harry Potter' for the Harry Potter books)
  3. Other books in the same series

knjk04 avatar Nov 21 '20 08:11 knjk04

Hi @knjk04 . Is it still open? I wanna work on this issue...

Sajal193 avatar Jan 20 '21 10:01 Sajal193

Hi, @Sajal193 . Yes, it is. Before I assign you to the issue, what's your implementation approach?

knjk04 avatar Jan 21 '21 08:01 knjk04

Hello, I would like to take a shot at this.

My proposal:

  • Create an Entity BookSeries with properties Series Id (Key), Name of Series, Series Order Number, Book Id (Foreign Key)
  • Modify Entity Book to add property Series Id (Foreign Key)

Does that make sense ?

kev711 avatar Feb 24 '21 08:02 kev711

Hello, thanks for your interest in this!

Create an Entity BookSeries with properties Series Id (Key), Name of Series, Series Order Number, Book Id (Foreign Key)

The Id ad name of the series sounds good.

Perhaps we don't need a series order number if a BookSeries contains an ordered (and unique) collection of books? Your approach sounds good, but how could we prevent different books from having the same series position?

knjk04 avatar Feb 24 '21 08:02 knjk04

I see an issue with my proposed approach where a Unique Series Id will relate to a single Book Id (When we need it to relate with multiple book id's).

Maybe we can:

  • Create a BookSeries entity with properties BookSeriesId (Key),SeriesName
  • Create a BookSeriesMapping entity with properties BookSeriesId (FK),BookId (FK),SerialNumber.
  • Skip any changes to Book entity.

As to have a unique SerialNumber for every BookSeriesId & BookId, I'm not sure if a UNIQUE constraint would work here. Any ideas ?

kev711 avatar Feb 25 '21 08:02 kev711

I confirmed that A UNIQUE(BookSeriesId, BookId, SerialNumber) constraint should work.

kev711 avatar Feb 26 '21 04:02 kev711

Does the serial number represent the order a book is in a series?

Create a BookSeriesMapping entity with properties BookSeriesId (FK),BookId (FK),SerialNumber.

So there would be a many-to-many relationship between Book and BookSeries. Is that correct?

Skip any changes to Book entity.

Sorry, what do you mean by 'skip' here?

knjk04 avatar Feb 26 '21 06:02 knjk04

Does the serial number represent the order a book is in a series?

Create a BookSeriesMapping entity with properties BookSeriesId (FK),BookId (FK),SerialNumber.

So there would be a many-to-many relationship between Book and BookSeries. Is that correct?

Skip any changes to Book entity.

Sorry, what do you mean by 'skip' here?

  • Yes serial number represents order of book in series.
  • Yes, there will be a many to many relationship between the two.
  • By skip, I meant I wont make any changes to Book entity.

kev711 avatar Feb 26 '21 09:02 kev711

@kev711 Thanks! Feel free to reach out by creating a GitHub discussion or by asking on our #help channel on Slack if you need anything!

knjk04 avatar Feb 26 '21 17:02 knjk04

@kev711 I think a book should be in at most one series and a series can contain many books. Should the relationship between series and book be many-to-one?

Also, we're now using Gradle & DGS, so I'd recommend rebasing your branch with main to get the new commits if you haven't already

knjk04 avatar Feb 28 '21 09:02 knjk04

I think in future, if the need arises to have a book in multiple series (e.g. Author specials, author etc.) then that would be needed.

kev711 avatar Feb 28 '21 09:02 kev711

@kev711 How are you getting on with this?

knjk04 avatar Mar 13 '21 06:03 knjk04

Still working on this. Not stuck as such, will create a PR on this in a few days.

kev711 avatar Mar 14 '21 06:03 kev711

That's fine, thanks for the update!

knjk04 avatar Mar 14 '21 08:03 knjk04

About this requirement, should these repository functions be a part of Entity Book or BookSeriesMapping ?

If a book is in a series, it should be possible to see:

  1. Its position in the series
  2. The name of the series (e.g. 'Harry Potter' for the Harry Potter books)
  3. Other books in the same series

kev711 avatar Mar 14 '21 19:03 kev711

Good question! I think it should be a part of the Book entity

knjk04 avatar Mar 15 '21 06:03 knjk04

@knjk04 I have created a PR for this.

kev711 avatar Mar 21 '21 12:03 kev711