0% found this document useful (0 votes)
10 views3 pages

Data Assignment 4

Uploaded by

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

Data Assignment 4

Uploaded by

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

Database Schema Overview

Tables

1. Books: Holds details about books in the library.


● ISBN (Primary Key)
● Title
● Author
● Genre
● Quantity

2. Members: Contains information about library members.


● MemberID (Primary Key)
● Name
● Email
● Phone

3. Loans: Tracks book loans.


● LoanID (Primary Key)
● MemberID (Foreign Key references Members.MemberID)
● ISBN (Foreign Key references Books.ISBN)
● LoanDate
● ReturnDate

SQL Script

Below is the SQL script implementing the schema, operations, and comments for clarity.

1
2
Explanation of the SQL Script

Schema Design:

● Books Table: Stores details about books, ensuring Quantity cannot be negative.
● Members Table: Holds member information with unique emails.
● Loans Table: Tracks loans and enforces referential integrity via foreign keys.

Sample Operations:

● Insert statements populate each table with sample data.


● Select query retrieves all books borrowed by a specific member (MemberID = 1).
● Update query reduces the quantity of a specific book.
● Delete query removes a member while maintaining database integrity.

References

Silberschatz, A., Korth, H. F., & Sudarshan, S. (2019). Database System Concepts. McGraw-Hill
Education.

You might also like