Database Management Assignment
Database Management Assignment
Assignment
1. Objective
The objective of this task is to design and implement a comprehensive SQL database for a
Management System that includes a variety of database operations such as DDL (Data
Definition Language), DML (Data Manipulation Language), Date Functions, String Functions,
Number Functions, the creation of an Entity-Relationship Diagram (ERD), and views to
simplify complex queries.
2. Problem Description
The Library Management System should handle various aspects such as book inventory,
member management, and transaction history. The system will need to store the following
information:
1. Books: Information related to books, including their titles, authors, publication dates,
and categories.
2. Members: Information about library members including their names, contact details,
membership status, and registration date.
3. Transactions: Information on when members borrow and return books, including due
dates, fines for late returns, etc.
4. Staff: Information about library staff who manage books and transactions.
Books
o title
o author
o category
o publication_date
o available_quantity
Members
o first_name
Pre Mids. Assignment
o last_name
o email
o phone
o membership_status
o registration_date
Transactions
o borrow_date
o return_date
o due_date
o fine_amount
Staff
o first_name
o last_name
o role
o hire_date
4. ERD Diagram
The Entity-Relationship Diagram should represent the relationships between the tables. The
Books table is related to the Transactions table via the book_id, while the Members table is
related to Transactions via the member_id. The Staff table is not directly related to Transactions
but will serve to manage various aspects of library operations.
Pre Mids. Assignment
5. Task Requirements
You are required to design the database schema by writing SQL statements for creating the
tables and defining constraints like Primary Key, Foreign Key, and Unique constraints.
1. Create a table for books with attributes like book_id, title, author, category,
publication_date, and available_quantity.
2. Create a table for members with attributes such as member_id, first_name, last_name,
email, phone, membership_status, and registration_date.
4. Create a table for staff with attributes like staff_id, first_name, last_name, role, and
hire_date.
1. Finding overdue books: Write a query to find transactions that are overdue.
2. Calculating fines: Write a query to calculate the fine based on overdue days (for
example, $1 per day).
3. Return date and due date calculations: Calculate the number of days a book is overdue
or due soon.
1. Concatenating first and last names: Write a query to concatenate the first and last
names of members into a single column (full name).
Pre Mids. Assignment
2. Searching for books: Write a query to find books whose titles start with a specific word,
for example, books that begin with "The".
1. Total number of available books: Write a query to calculate the total number of
available books in the library (sum of available_quantity in the Books table).
2. Average fine: Write a query to find the average fine amount for overdue transactions.
3. Counting books in a category: Write a query to count how many books belong to a
specific category.
5.6. Views
Create views that simplify complex queries for reporting or frequently accessed data:
1. Overdue Books View: Create a view that lists overdue books along with member details
and fine amounts.
2. Available Books View: Create a view that lists the available books in the library (with
details such as title, author, and category).
3. Members with Active Status View: Create a view that shows members who have an
active membership status, including their details.
6. Submission Requirements
1. SQL Script: The complete SQL script including DDL, DML, and queries for date, string,
and number functions, along with views.
3. Test Cases: Provide SQL queries to test the functionality of your system (e.g., adding
members, borrowing books, calculating fines).
This task provides you with a comprehensive understanding of database design, SQL queries,
and operations. You will gain practical experience in designing and querying databases using a
variety of SQL functions, including views to simplify the complexity of data retrieval.