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

Library Management System

Uploaded by

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

Library Management System

Uploaded by

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

Designing a Library Database

Database Concepts and SQL Queries


Normalization:

First Normal Form (1NF): Ensure each attribute contains only atomic values (e.g.,
no lists or arrays within a single cell).
Second Normal Form (2NF): Eliminate partial dependencies. All non-key attributes
should be fully dependent on the primary key.
Third Normal Form (3NF): Remove transitive dependencies. No non-key attribute
should be dependent on another non-key attribute.
Data Types:

INTEGER: For numerical data (e.g., book ID, member ID).


VARCHAR: For variable-length character strings (e.g., book title, author name).
DATE: For date values (e.g., publication date, due date).
Relationships:

One-to-Many: A single entity can be related to multiple entities of another type


(e.g., one author can write many books).
Many-to-Many: Multiple entities of one type can be related to multiple entities of
another type (e.g., many members can borrow many books).

Table Creation

1. Books
CREATE TABLE Books (
BookID INTEGER PRIMARY KEY,
Title VARCHAR(100),
Author VARCHAR(100),
PublicationDate DATE,
Genre VARCHAR(50)
);

2. Members

CREATE TABLE Members (


MemberID INTEGER PRIMARY KEY,
Name VARCHAR(100),
Address VARCHAR(200),
ContactNumber VARCHAR(20)
);

3. Loans
CREATE TABLE Loans (
LoanID INTEGER PRIMARY KEY,
BookID INTEGER,
MemberID INTEGER,
LoanDate DATE,
DueDate DATE,
ReturnDate DATE,
FOREIGN KEY (BookID) REFERENCES Books(BookID),
FOREIGN KEY (MemberID) REFERENCES Members(MemberID)
);

SQL Queries
List all books by a specific author:

SELECT * FROM Books WHERE Author = 'J.K. Rowling';


Find all members who have overdue books:
SELECT * FROM Members
INNER JOIN Loans ON Members.MemberID = Loans.MemberID
WHERE Loans.DueDate < CURRENT_DATE();

Calculate the total number of books borrowed by a specific member:


SELECT COUNT(*) FROM Loans WHERE MemberID = 123;

Additional Considerations:

Indexes: Create indexes on frequently searched columns (e.g., BookID in the Loans
table) to improve query performance.
Data Integrity: Implement constraints (e.g., NOT NULL, UNIQUE) to ensure data
consistency.
Security: Consider security measures like user authentication and access control.
Scalability: Design the database to accommodate future growth and changes in
requirements.
This is a basic foundation for a library database. You can extend it further by
adding tables for genres, publishers, and more.

You might also like