Assignment
Assignment
You are required to create a database schema for managing a library system with the following
1. Books with attributes:: ISBN (Primary Key), Title, Author, Genre, Quantity
Genre VARCHAR(100),
);
Phone VARCHAR(15)
);
3. Loans with attributes:: LoanID (Primary Key), MemberID (Foreign Key), ISBN (Foreign
MemberID INT,
ISBN VARCHAR(13),
ReturnDate DATE,
);
Once the database schema is designed, implement the following SQL queries. Provide
screenshots of the executed queries and the resulting records from the tables.
1. Insert Records
Write SQL INSERT statements to add new records into each of the following tables:
- Books
- Members
- Loans
VALUES ('978-3-16-148410-0', 'The Great Gatsby', 'F. Scott Fitzgerald', 'Fiction', 5);
INSERT INTO Members (Name, Email, Phone) VALUES ('John Doe', '[email protected]',
'1234567890');
Inserting a record into the Loans table:
FROM Members
UPDATE Books
-- Create the Books table to store information about books in the library
CREATE TABLE Books (
ISBN VARCHAR(13) PRIMARY KEY, -- Unique identifier for each book (ISBN)
);
Email VARCHAR(255) UNIQUE NOT NULL, -- Email address of the member (must be
unique)
Phone VARCHAR(15) -- Phone number of the member (optional)
);
LoanID INT PRIMARY KEY AUTO_INCREMENT, -- Unique identifier for each loan
LoanDate DATE NOT NULL, -- Date when the book was loaned out
Books table
);
The Books table holds data about each book, including its ISBN, title, author, genre, and
quantity available.
The Members table contains details of library members, such as their IDs, names,
The Loans table records the transactions of books being loaned out, including which
member borrowed which book, when it was borrowed, and when it was returned.
References
Vidhya, V., Jeyaram, G., & Ishwarya, K. (2016). Database management systems. Alpha Science
International.
Peterson, R. (2023, December 9). Functional dependency in DBMS: What is, types and
examples. Guru99. https://www.guru99.com/dbms-functional-dependency.html
Peterson, R. (2023, December 26). What is normalization in DBMS (SQL)? 1NF, 2NF, 3NF
example. Guru99. https://www.guru99.com/database-normalization.html