Skip to content

Library Management System built using PostgreSQL in pgAdmin 4. The system manages book issuing, returns, and tracking with detailed records of books, members, employees, branches, and transactions. It supports CRUD operations on books and members, and helps streamline library workflows efficiently.

License

Notifications You must be signed in to change notification settings

ParthDS02/Library-System-Management-SQL

Repository files navigation

Library Management System using SQL

Project Overview

Project Title: Library Management System
Database: library_db

This project demonstrates the implementation of a Library Management System using SQL. It includes creating and managing tables, performing CRUD operations, and executing advanced SQL queries. The goal is to showcase skills in database design, manipulation, and querying.

Library-System-Management

Objectives

  1. Set up the Library Management System Database: Create and populate the database with tables for branches, employees, members, books, issued status, and return status.
  2. CRUD Operations: Perform Create, Read, Update, and Delete operations on the data.
  3. CTAS (Create Table As Select): Utilize CTAS to create new tables based on query results.
  4. Advanced SQL Queries: Develop complex queries to analyze and retrieve specific data.

Project Structure

1. Data Model

Data Model

This is a relational data model for a Library Management System created using PostgreSQL. The schema consists of multiple interconnected tables:

  • Branch: Contains details about library branches including branch_id, address, and manager information.

  • Employees: Contains employee data like emp_id, name, position, salary, and the branch they work at.

  • Members: Stores member details such as member_id, name, address, and registration date.

  • Books: Holds book information including isbn, title, category, rental price, and author details.

  • Issued Status: Manages information about books issued to members, containing data like issued_id, issued_member_id, issued_book_isbn, issued_emp_id, and dates.

  • Return Status: Tracks details about book returns, including return_id, return_book_name, return_date, and return_book_isbn.

  • The tables are connected using foreign keys such as branch_id (in both Branch and Employees), isbn (in Books and Issued Status), and member_id (in Members and Issued Status), enabling data relationships for tracking library operations.

  • Database Creation: Created a database named library_db.

  • Table Creation: Created tables for branches, employees, members, books, issued status, and return status. Each table includes relevant columns and relationships.

CREATE DATABASE library_db;

DROP TABLE IF EXISTS branch;
CREATE TABLE branch
(
            branch_id VARCHAR(10) PRIMARY KEY,
            manager_id VARCHAR(10),
            branch_address VARCHAR(30),
            contact_no VARCHAR(15)
);


-- Create table "Employee"
DROP TABLE IF EXISTS employees;
CREATE TABLE employees
(
            emp_id VARCHAR(10) PRIMARY KEY,
            emp_name VARCHAR(30),
            position VARCHAR(30),
            salary DECIMAL(10,2),
            branch_id VARCHAR(10),
            FOREIGN KEY (branch_id) REFERENCES  branch(branch_id)
);


-- Create table "Members"
DROP TABLE IF EXISTS members;
CREATE TABLE members
(
            member_id VARCHAR(10) PRIMARY KEY,
            member_name VARCHAR(30),
            member_address VARCHAR(30),
            reg_date DATE
);



-- Create table "Books"
DROP TABLE IF EXISTS books;
CREATE TABLE books
(
            isbn VARCHAR(50) PRIMARY KEY,
            book_title VARCHAR(80),
            category VARCHAR(30),
            rental_price DECIMAL(10,2),
            status VARCHAR(10),
            author VARCHAR(30),
            publisher VARCHAR(30)
);



-- Create table "IssueStatus"
DROP TABLE IF EXISTS issued_status;
CREATE TABLE issued_status
(
            issued_id VARCHAR(10) PRIMARY KEY,
            issued_member_id VARCHAR(30),
            issued_book_name VARCHAR(80),
            issued_date DATE,
            issued_book_isbn VARCHAR(50),
            issued_emp_id VARCHAR(10),
            FOREIGN KEY (issued_member_id) REFERENCES members(member_id),
            FOREIGN KEY (issued_emp_id) REFERENCES employees(emp_id),
            FOREIGN KEY (issued_book_isbn) REFERENCES books(isbn) 
);



-- Create table "ReturnStatus"
DROP TABLE IF EXISTS return_status;
CREATE TABLE return_status
(
            return_id VARCHAR(10) PRIMARY KEY,
            issued_id VARCHAR(30),
            return_book_name VARCHAR(80),
            return_date DATE,
            return_book_isbn VARCHAR(50),
            FOREIGN KEY (return_book_isbn) REFERENCES books(isbn)
);

About

Library Management System built using PostgreSQL in pgAdmin 4. The system manages book issuing, returns, and tracking with detailed records of books, members, employees, branches, and transactions. It supports CRUD operations on books and members, and helps streamline library workflows efficiently.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published