Library Management

Why In Library Management
Both Rack and Librarian have a two-way association with BookItem.
The Notification has a two-way association with BookLending and BookReservation.
The BookLending has a two-way association with BookReservation and User.

And why book item does not have a composition relation with Rack? Like if there is no rack we can’t place any books, similarly why rack does not have a composition relation with Library?


Course: Grokking the Low Level Design Interview Using OOD Principles - Learn Interactively
Lesson: Class Diagram for the Library Management System - Grokking the Low Level Design Interview Using OOD Principles

Hi @Rajat_Saraf,

For the Librarian — BookItem, a BookItem can be checked out or returned by a Librarian, and a Librarian can access the BookItem’s information, such as its availability, due date, and borrower information. A Librarian can add new BookItems to the library’s collection.

For the BookItem — Librarian, a BookItem can be associated with a specific Librarian who checked it out or returned it. Therefore, it is appropriate to represent the relationship between BookItem and Librarian as a two-way association.

For the BookItem — Rack, a Rack can contain multiple BookItems, and a BookItem can be placed on a Rack. The “contains” or “holds” relationship allows a Rack object to keep track of the BookItems it holds, such as their availability and location on the rack. Similarly, a BookItem object can access information about the Rack it is placed on, such as the rack number and location within the library. Therefore, the relationship between BookItem and Rack can be modeled as a two-way association.

The two-way association between BookLending, BookReservation, and User allows for more effective management of the library’s collection and ensures that books are borrowed and returned in an organized and efficient manner.

For LibraryCard — BarcodeReader class it would not be appropriate to say that a BarcodeReader is composed of a LibraryCard, because a BarcodeReader can function without a specific LibraryCard (for example, as mentioned if it is used to scan a book instead of a member’s library card). Therefore, an association relationship is preferred for the relationship between LibraryCard and BarcodeScanner.

The BarcodeReader object can scan multiple LibraryCard objects, and each LibraryCard object can be scanned by multiple BarcodeReader objects. Therefore, an association relationship is preferred for the relationship between LibraryCard and BarcodeScanner.

Happy Learning :slight_smile: