Design a Library Management System

Shivam Sinha
3 min readFeb 11, 2021

--

A Library Management System is a software built to handle the functions of a library. It helps to keep track of books and their checkouts as well as library members and their profiles.

Library management systems also involve maintaining the database for entering new books and recording books that have been borrowed with their respective due dates.

Let’s first focus on the requirements:

  1. Member can search for books by their author, title or publication date.
  2. Each Book will have a unique id and rack number where a book is physically placed.
  3. A book can have multiple copies, and member can checkout any copy.
  4. The system can retrieve information about a particular book.
  5. There should be a maximum limit (5) on how many books a member can check-out.
  6. There should be a maximum limit (10) on how many days a member can keep a book.
  7. The system should be able to collect fines for books returned after the due date.
  8. Each member will have a library card with a unique barcode.

Main Actors:

Librarian: Responsible for adding or modifying books, book items, users. The Librarian can also issue and return book items.

Member: All members can search the catalog and check-out, renew, and return a book.

Use Cases:

  1. Add/Remove/Edit Books
  2. Register new account/cancel membership
  3. Checkout book
  4. Renew a book
  5. Return a book

Main Classes:

  1. Book: Represent a unique book with Title, Subject, Publishers etc.
  2. BookItem: A book can have multiple copies; each copy will be considered a book item with a unique barcode.
  3. Account: We have two types of account Member and Librarian.
  4. LibraryCard: Each member will be issued a library card, which will be used to identify users while issuing and returning books.
  5. BookLending: Manage the checking-out of book items.
  6. Fine: This class will be responsible for calculating and collecting fines from library members.
  7. Author: This class will encapsulate a book author.
  8. Rack: Books will be placed on racks. Each rack will be identified by a rack number and will have a location identifier to describe the physical location of the rack in the library.
  9. Fine: This class will be responsible for calculating and collecting fines from library members.

Implementation:

Enums and Constants:

public enum BookStatus {
AVAILABLE,
LOANED,
LOST
}

public enum AccountStatus{
ACTIVE,
CLOSED,
BLACKLISTED
}
public class Constants {
public static final int MAX_BOOKS_ISSUED_TO_A_USER = 5;
public static final int MAX_LENDING_DAYS = 10;
}

Account, Librarian, Member and LibraryCard:

public class LibraryCard{
private string cardNumber;
private string barCode;
private Date issuedAt;
private boolean isActive;
}
public class Account {
private String id;
private String userName;
private String password;
private AccountStatus status;
private LibraryCard libraryCard;
public bool resetPassword();
}
public class Librarian extends Account {
public boolean addBookItem(BookItem bookItem);
public boolean blockMember(Member member);
public boolean unBlockMember(Member member);
public boolean cancelMembership(Member member);
}
public class Member extends Account {
private Date dateOfMembership;
private int totalBooksCheckedout;
public incrementTotalBooksCheckedout();
public checkoutBook(BookItem item);
public returnBookItem(BootItem item);
public renewBookItem(BootItem item);
public checkForFine(String barCode);
}
public class Author extends Account {
private int booksPublished;
List<Book> book;
}

Book, BookItem and Rack:

public abstract class Book {
private String title;
private String subject;
private String publisher;
private int numberOfPages;
private List<Author> authors;
}

public class BookItem extends Book {
private String barcode;
private boolean isReferenceOnly; //not eligible for checkout
private Date borrowed;
private Date dueDate;
private double price;
private BookStatus status;
private Date dateOfPurchase;
private Date publicationDate;
private Rack placedAt;
}

public class Rack {
private int number;
private String locationIdentifier;
}

BookLending and Fine:

public class BookLending {
private Date creationDate;
private Date dueDate;
private Date returnDate;
private String bookItemBarcode;
private String memberId;

public static void lendBook(String barcode, String memberId);
public static BookLending fetchLendingDetails(String barcode);
}
public class Fine {
private Date creationDate;
private double bookItemBarcode;
private String memberId;
private double amount;
public static void collectFine(String memberId, long days);
}

Search interface and Catalog:

public interface Search {
public List<Book> searchByTitle(String title);
public List<Book> searchByAuthor(String author);
public List<Book> searchBySubject(String subject);
public List<Book> searchByPubDate(Date publishDate);
}

public class Catalog implements Search {
private HashMap<String, List<Book>> bookTitles;
private HashMap<String, List<Book>> bookAuthors;
private HashMap<String, List<Book>> bookSubjects;
private HashMap<String, List<Book>> bookPublicationDates;

public List<Book> searchByTitle(String query) {
return bookTitles.get(query);
}

public List<Book> searchByAuthor(String query) {
return bookAuthors.get(query);
}
public List<Book> searchBySubject(String query) {
return bookSubjects.get(query);
}

public List<Book> searchByPubDate(Date query) {
return bookPublicationDates.get(query);
}
}

ThankYou. Please do give suggestions.

--

--

Responses (3)