Design A Library Management System
Design A Library Management System
EXPLORE
TRACKS
MY COURSES
EDPRESSO
REFER A FRIEND
CREATE
Search Course
Object-Oriented Basics
What is UML?
Class Diagram
Preview
Sequence diagram
Activity Diagrams
Object Oriented Design Case Studies
Design an ATM
Design Chess
Design LinkedIn
Design Cricinfo
Contact us
Preview
Other courses
Preview
Library management systems also involve maintaining the database for entering new books and recording books that have been borrowed with their respective due dates.
System Requirements
Always clarify requirements at the beginning of the interview. Be sure to ask questions to find the exact scope of the system that the interviewer has in mind.
We will focus on the following set of requirements while designing the Library Management System:
1. Any library member should be able to search books by their title, author, subject category as well by the publication date.
2. Each book will have a unique identification number and other details including a rack number which will help to physically locate the book.
3. There could be more than one copy of a book, and library members should be able to check-out and reserve any copy. We will call each copy of a book, a book item.
4. The system should be able to retrieve information like who took a particular book or what are the books checked-out by a specific library member.
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. Members should be able to reserve books that are not currently available.
9. The system should be able to send notifications whenever the reserved books become available, as well as when the book is not returned within the due date.
10. Each book and member card will have a unique barcode. The system will be able to read barcodes from books and members’ library cards.
Librarian: Mainly responsible for adding and modifying books, book items, and users. The Librarian can also issue, reserve, and return book items.
Member: All members can search the catalog, as well as check-out, reserve, renew, and return a book.
System: Mainly responsible for sending notifications for overdue books, canceled reservations, etc.
Here are the top use cases of the Library Management System:
Class diagram
Here are the main classes of our Library Management System:
Library: The central part of the organization for which this software has been designed. It has attributes like ‘Name’ to distinguish it from any other libraries and ‘Address’ to describe its location.
Book: The basic building block of the system. Every book will have ISBN, Title, Subject, Publishers, etc.
BookItem: Any book can have multiple copies, each copy will be considered a book item in our system. Each book item will have a unique barcode.
Account: We will have two types of accounts in the system, one will be a general member, and the other will be a librarian.
LibraryCard: Each library user will be issued a library card, which will be used to identify users while issuing or returning books.
Catalog: Catalogs contain list of books sorted on certain criteria. Our system will support searching through four catalogs: Title, Author, Subject, and Publish-date.
Fine: This class will be responsible for calculating and collecting fines from library members.
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.
Notification: This class will take care of sending notifications to library members.
Class diagram for Library Management System
UML conventions
<<interface>>
Name
Interface: Classes implement interfaces, denoted by Generalization.
method1()
ClassName
property_name: type Class: Every class can have properties and methods.
Abstract classes are identified by their Italic names.
method(): type
A B Generalization: A implements B.
Activity diagrams
Check-out a book: Any library member or librarian can perform this activity. Here are the set of steps to check-out a book:
[no]
[yes]
[else]
[yes]
[no]
System updates the status of the book to 'Loaned' Show error message
System increments number of books issued to the member
Return a book: Any library member or librarian can perform this activity. The system will collect fines from members if they return books after the due date. Here are the steps for returning a book:
[no]
Calculate fine
[yes]
[no]
Renew a book: While renewing (re-issuing) a book, the system will check for fines and see if any other member has not reserved the same book, in that case the book item cannot be renewed. Here are the different steps for renewing a book:
[no]
Calculate fine
[yes]
[no]
Code
Here is the code for the use cases mentioned above: 1) Check-out a book, 2) Return a book, and 3) Renew a book.
Note: This code only focuses on the design part of the use cases. Since you are not required to write a fully executable code in an interview, you can assume parts of the code to interact with the database, payment system, etc.
Enums and Constants: Here are the required enums, data types, and constants:
Java
Java
Java
Python
Python
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Account, Member, and Librarian: These classes represent various people that interact with our system:
Java
Java
Java
Python
Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
BookReservation, BookLending, and Fine: These classes represent a book reservation, lending, and fine collection, respectively.
Java
Java
Java
Python
Python
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
BookItem: Encapsulating a book item, this class will be responsible for processing the reservation, return, and renewal of a book item.
Java
Java
Java
Python
Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Search interface and Catalog: The Catalog class will implement the Search interface to facilitate searching of books.
Java
Java
Java
Python
Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Mark as Completed
← Back
Activity Diagrams
Next →
Design a Parking Lot
Stuck? Get help on DISCUSS
Send feedback
34 Recommendations