educative.io

With this design how are we going to figure out which bookItem belongs to which member?

This is one of the requirements listed in “System Requirements”

Hi Shrishty Chandra,

Thanks for putting up your question.

If we want to know which user has borrowed a particular book-item, we have to look into “BookLending” table. This table is connected with “BookItem” and the “Account” table, which means, for every BookLending transaction it will record the ‘barcode’ of the BookItem and ‘id’ of the Account in this table. So for the book-item we are interested in, we can search its barcode in the BookLending table to find which user has borrowed it.

Hopefully this answered your question.

Thanks for the early response and clarifying my question.

BookLending class ,however, has only three data? ??? creationDate, Due date and return date but not barcode of BookItem and ‘id’ of account

2 Likes

Did you get any answer? I’m also confused about this BookLending class. Thanks.

In a “class diagram”, we only show relationships between classes. In code, it gets realized with all the proper IDs.

For example, the BookLending class has a “unidirectional association” with the BookItem class with a multiplicity of “1”. This means, there will be one BookItem for each BookLending class object. Therefore, in the code, we have added the BookItemBarcode in the BookLending class.

If, for example, there are multiple BookItems for a BookLending (meaning a “*” multiplicity), we will be having a list (or array) of BookItemBarcode in the BookLending class.