1. Introduction
The Library Management System (LMS) is a simple database project designed to manage books and their details in a library. It helps keep track of available books, authors, and prices while supporting easy queries to retrieve and manage data. This project demonstrates the use of SQL in Oracle Live SQL for creating tables, inserting records, and running queries.
2. Objectives
To store and manage details of books in a structured way.
To allow easy insertion of book details like title, author, and price.
To retrieve information such as all available books, sorted book lists, and price filtering.
To provide a foundation for a scalable system that can be extended with members, borrowing records, and transactions in the future.
3. Database Schema
The project contains a Books table with the following attributes:
BookID (NUMBER, Primary Key) – Unique ID for each book.
Title (VARCHAR2) – Name of the book.
Author (VARCHAR2) – Author of the book.
Price (NUMBER) – Price of the book.
4. SQL Code
-- Drop table if it exists
BEGIN
EXECUTE IMMEDIATE 'DROP TABLE Books';
EXCEPTION
WHEN OTHERS THEN
IF SQLCODE != -942 THEN
RAISE;
END IF;
END;
/
-- Create table
CREATE TABLE Books (
BookID NUMBER PRIMARY KEY,
Title VARCHAR2(200) NOT NULL,
Author VARCHAR2(100),
Price NUMBER(10,2)
);
-- Insert sample records
INSERT INTO Books VALUES (1, 'The Great Gatsby', 'F. Scott Fitzgerald', 300.50);
INSERT INTO Books VALUES (2, 'To Kill a Mockingbird', 'Harper Lee', 250.75);
INSERT INTO Books VALUES (3, '1984', 'George Orwell', 200.00);
INSERT INTO Books VALUES (4, 'Pride and Prejudice', 'Jane Austen', 150.25);
-- Retrieve all records
SELECT * FROM Books;
-- Find books priced above 200
SELECT * FROM Books WHERE Price > 200;
-- Sort books by price
SELECT * FROM Books ORDER BY Price DESC;
Here's the output of my code:
Show all books ordered by price (descending)
Top comments (0)