0% found this document useful (0 votes)
2 views2 pages

Library Management System

The document outlines the SQL commands to create a library database named LibraryDB, including tables for Members, Books, IssuedBooks, and Fines. It also includes sample data insertion for members, books, issued books, and fines. The structure supports tracking of book loans and associated fines for members.

Uploaded by

076r2trryw
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Library Management System

The document outlines the SQL commands to create a library database named LibraryDB, including tables for Members, Books, IssuedBooks, and Fines. It also includes sample data insertion for members, books, issued books, and fines. The structure supports tracking of book loans and associated fines for members.

Uploaded by

076r2trryw
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

-- Create Database

CREATE DATABASE LibraryDB;


USE LibraryDB;

-- Table: Members
CREATE TABLE Members (
member_id INT AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(50),
last_name VARCHAR(50),
contact_number VARCHAR(15),
email VARCHAR(100),
join_date DATE
);

-- Table: Books
CREATE TABLE Books (
book_id INT AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(100),
author VARCHAR(100),
publisher VARCHAR(100),
publication_year INT,
available_copies INT
);

-- Table: IssuedBooks
CREATE TABLE IssuedBooks (
issue_id INT AUTO_INCREMENT PRIMARY KEY,
book_id INT,
member_id INT,
issue_date DATE,
due_date DATE,
return_date DATE,
FOREIGN KEY (book_id) REFERENCES Books(book_id),
FOREIGN KEY (member_id) REFERENCES Members(member_id)
);

-- Table: Fines
CREATE TABLE Fines (
fine_id INT AUTO_INCREMENT PRIMARY KEY,
issue_id INT,
fine_amount DECIMAL(10,2),
paid_status ENUM('Paid', 'Unpaid') DEFAULT 'Unpaid',
FOREIGN KEY (issue_id) REFERENCES IssuedBooks(issue_id)
);
-- Insert Members
INSERT INTO Members (first_name, last_name, contact_number, email, join_date) VALUES
('John', 'Doe', '9876543210', '[email protected]', '2023-01-15'),
('Jane', 'Smith', '9876543211', '[email protected]', '2023-03-10');

-- Insert Books
INSERT INTO Books (title, author, publisher, publication_year, available_copies) VALUES
('The Great Gatsby', 'F. Scott Fitzgerald', 'Scribner', 1925, 3),
('1984', 'George Orwell', 'Secker & Warburg', 1949, 2),
('To Kill a Mockingbird', 'Harper Lee', 'J.B. Lippincott & Co.', 1960, 4);

-- Issue Books
INSERT INTO IssuedBooks (book_id, member_id, issue_date, due_date, return_date) VALUES
(1, 1, '2024-06-01', '2024-06-15', '2024-06-20'),
(2, 2, '2024-06-05', '2024-06-19', '2024-06-18');

-- Insert Fines
INSERT INTO Fines (issue_id, fine_amount, paid_status) VALUES
(1, 50.00, 'Unpaid');

You might also like