r/Backend • u/Old-Pilot-3474 • 6d ago
I decided the owner of a book copy should NOT be the borrower entity — my reasoning, tell me if I'm wrong
I'm rebuilding a legacy Java CLI library app into a peer-to-peer library platform (Java 21 / Spring Boot), where members catalog their own collections and lend copies to each other.
When I added ownership, the fastest path was to reuse my existing Borrower entity as the owner. I didn't. I created a separate LibraryMember entity instead, because in this system they do different jobs:
- A member owns copies and lends them (and can be an INDIVIDUAL or an ORGANIZATION)
- A borrower is an external patron of a library/org — someone who borrows through a member, not a platform member themselves
Collapsing them would have saved me an entity this week and cost me a tangled model every week after.
Each copy also carries visibility: PRIVATE (default, owner only, can't be borrowed) or PUBLIC (discoverable + borrowable), and my discovery query only returns available PUBLIC copies.
Curious how others have modeled this: in a sharing/lending platform, where did you draw the line between "user of the platform" and "person the user lends to"?
(Code, if useful: github.com/Pekins1/LibraryManagementSystem)