Design a library management system
medium 85 minModel a lending library: titles and copies, members with plans, loans, a waiting list and fines.
Watch lesson4:58
Where it shows up
The same pattern appears across everyday software.
BIBFRAME: work, instance, item
The Library of Congress model has three levels. An item is an actual copy, with its location, shelf mark and barcode. Instance and item are our title and copy.
Open Library: works and editions
Its public API has works and editions as separate resources. A step above our title: several editions of one work.
Koha: fine rules as data
The circulation rules of this free library system are a table: fine amount, interval, grace period and a cap for each item, by patron category and item type. Our `Plan`, editable by staff.
Evergreen: levels of holds
A hold can be for a title, a part, a call number or one copy. Patrons can place title holds; a hold for one barcode is for staff. The queue by title of this page.
Evergreen: copy statuses
Available, Checked out, Lost, Missing, In transit, On holds shelf, Damaged, Lost and Paid and more. A longer enum, with flags for holdable and visible.
FOLIO: loan policies and anonymization
In this open source platform, loan, overdue fine and request policies are settings, and closed loans can be anonymized after a time.
Internet Archive lending
Books can be borrowed for one hour, and some for 14 days. For those a waitlist exists when all copies are out.
PostgreSQL: partial unique index
The manual shows a unique index over part of a table. One open loan for each copy is exactly this.
Debezium: outbox event router
A ready-made piece for the outbox pattern: rows written with a change become messages, so that the two cannot disagree.
Java: LongAdder
Its documentation prefers it to AtomicLong for sums that many threads update, such as statistics, and not for fine-grained control.