Database Design · SQL Analysis · Oracle

Library Database:
SQL Schema & Query Analysis

Tools
Oracle SQL · DDL · DML · Joins · Subqueries
Tables Designed
Authors · Books · Members · Loans · Reservations
Collection Scale
25 Titles · 15 Authors · 54 Total Copies
Queries Written
15 Queries · Simple SELECT to Correlated Subquery
Jump to → Genre Filter Collection SQL Queries ⚠ Risks ✓ Recommendations

Objective: Design a fully normalised relational library database in Oracle SQL, populate it with 25 books by 15 classic and contemporary authors, and write 15 analytical queries demonstrating a range of techniques from basic SELECT to correlated subqueries and self-joins.

Key Finding: The collection holds 54 copies across 25 titles and 10 genres, with an overall availability rate of 61%. Mystery and Horror have the lowest availability (25% and 40% respectively), with 3 titles fully checked out. 5 active reservations signal a backlog. Two schema-level defects were identified — a syntax error in the final query and a typo in a CHECK constraint.

25
Unique Titles
Across 10 genres — from Dystopian Fiction to Magical Realism
61%
Availability Rate
33 of 54 copies on the shelf; 21 currently checked out
3
Fully Unavailable
The Shining, Orient Express & War and Peace — zero copies left
15
SQL Queries
Covering 7 distinct techniques: SELECT through correlated subqueries

Filter by Genre

Select a genre to explore individual titles. The chart updates to show each book's total and available copies. The table filters accordingly.

Fig 01 — Books per Genre: Collection Distribution
Tab 01 — Library Book Catalog (Selected Titles) 10 titles
Title Author Genre Total Copies Available Status
1984George OrwellDystopian Fiction31Partial
The Handmaid's TaleMargaret AtwoodDystopian Fiction31Partial
War and PeaceLeo TolstoyHistorical Fiction10Unavailable
A Farewell to ArmsErnest HemingwayHistorical Fiction22Available
HP: Sorcerer's StoneJ.K. RowlingFantasy42Partial
HP: Chamber of SecretsJ.K. RowlingFantasy33Available
The ShiningStephen KingHorror20Unavailable
Murder on Orient ExpressAgatha ChristieMystery20Unavailable
The Great GatsbyF. Scott FitzgeraldClassic32Partial
One Hundred Years of SolitudeGabriel García MárquezMagical Realism21Partial

Availability & Genre Coverage

Fig 02 — Total vs Available Copies by Genre
Fig 03 — Copies Checked Out (Demand Pressure) per Genre

Query Complexity & Technique Coverage

15 queries were written covering the full spectrum of Oracle SQL — from basic data retrieval to multi-level correlated subqueries and set operations. The chart maps each technique to the number of queries that employ it.

Fig 04 — SQL Techniques: Frequency Across 15 Queries

⚠ Schema & Data Quality Risks

⚠ No fine or penalty tracking in the loans table
Query 11 calculates overdue days using SYSDATE - due_date, but the schema has no column to record fine amounts or payment status. Overdue logic exists in queries but not in the data model — this is an incomplete design that would require schema changes before production use.

✓ Recommendations

→ Acquire additional copies of the three fully unavailable titles
The Shining (2 reservations), Murder on the Orient Express, and War and Peace each have active reservation queues with zero copies on the shelf. A single additional copy of each would clear the backlog immediately. War and Peace is especially risky, one copy means any loss permanently removes the title.
→ Extend the loans table to support fine calculation
Add a fine_per_day NUMBER DEFAULT 0.50 and a fine_paid VARCHAR2(3) DEFAULT 'NO' column to the loans table. This would make Query 11 actionable — turning an analytical query into an operational tool for library staff to manage overdue collections. The analytical foundation already exists; only the schema needs extending.