Database Assignment (Group 2)
Database Assignment (Group 2)
Name Student ID
Page 1/25
Sunway DIIT Database Fundamental I
Table of Content
1. Introduction
1.2 Objectives
3. Relationship Schema
4. Data Dictionary
5. SQL Statements
6. Conclusion
Page 2/25
Sunway DIIT Database Fundamental I
1. INTRODUCTION
Welcome to Comics & Novels Rental Company. This is a database designed to manage
the company’s essential data for the smooth and efficient running of the book rental
operations. We call the database ‘BookRentalCo’. The key data include the following are:
Branch
Staff
Customer + cTel (Multivalue Attribute)
Book (Catalogue)
Author + AuthorCatalogue (Multivalue Attribute)
BookCopies (Stock)
Rental
Comins & Novels Rental Company is a Malaysian company with branches in Malaysia.
Customers are allowed to rent books from any of our branches throughout Malaysia using
the same customer ID.
Page 3/25
Sunway DIIT Database Fundamental I
Page 4/25
Sunway DIIT Database Fundamental I
3. RELATIONAL SCHEMA
Page 5/25
Sunway DIIT Database Fundamental I
4. DATA DICTIONARY
Branch
Attribute Type Constraint Key Description
Staff
Attribute Type Constraint Key Description
Page 6/25
Sunway DIIT Database Fundamental I
Customer
Attribute Type Constraint Key Description
Page 7/25
Sunway DIIT Database Fundamental I
Book
Attribute Type Constraint Key Description
Author
Attribute Type Constraint Key Description
Page 8/25
Sunway DIIT Database Fundamental I
BookCopies
Attribute Type Constraint Key Description
Rental
Attribute Type Constraint Key Description
Page 9/25
Sunway DIIT Database Fundamental I
5. SQL STATEMENTS
Page 10/25
Sunway DIIT Database Fundamental I
Page 11/25
Sunway DIIT Database Fundamental I
Page 12/25
Sunway DIIT Database Fundamental I
Page 13/25
Sunway DIIT Database Fundamental I
Page 14/25
Sunway DIIT Database Fundamental I
Page 15/25
Sunway DIIT Database Fundamental I
Page 16/25
Sunway DIIT Database Fundamental I
Page 17/25
Sunway DIIT Database Fundamental I
Page 18/25
Sunway DIIT Database Fundamental I
Page 19/25
Sunway DIIT Database Fundamental I
List all the stock at Sunway branch. The list should consist of book number, title, quantity on
hand, unit price, author’s ID and names.
SELECT
bookcopies.bkID, bkCatID, bkBID, bkStatus,
book.Title, quantityOnHand, Cost,
author.aID, aFName, aLName
FROM
bookcopies
LEFT JOIN book
ON book.catID = bookcopies.bkCatID
LEFT JOIN authorcatalogue
ON bookcopies.bkCatID=authorcatalogue.aCatID
LEFT JOIN author
ON author.aID = authorcatalogue.arID;
Note: 1. The list returns multiple rows due to the presence of co-authors.
2. B0001 is Sunway branch.
3. Cost = Unit Price of book.
Page 20/25
Sunway DIIT Database Fundamental I
List all the rental of January 2021. The list should consist of member number, member
name, rental number, book number, title, date out, date returned and daily rental.
SELECT
rental.rID, rBkID, rDateRented, rDateReturned,
book.title, dailyRental,
customer.cID, cFName, cLName
FROM
customer
LEFT JOIN rental
ON customer.cID = rental.rCID
LEFT JOIN bookcopies
ON bookcopies.bkID = rental.rBkID
LEFT JOIN book
ON book.catID = bookcopies.bkCatID
WHERE MONTH (rDateRented)= '1';
Page 21/25
Sunway DIIT Database Fundamental I
SELECT
author.aFName, aLName,
authorCatalogue.*,
book.Title
FROM
book
INNER JOIN authorCatalogue
ON book.catID = authorCatalogue.aCatID
INNER JOIN author
ON author.aID = authorcatalogue.arID;
Page 22/25
Sunway DIIT Database Fundamental I
SELECT
customer.cID, cFName, cLName,
rental.*
FROM
customer
LEFT JOIN rental
ON customer.cID = rental.rCID
WHERE rental.rID is null;
Page 23/25
Sunway DIIT Database Fundamental I
List all the book details that had been rented by Gloria in January 2021.
SELECT
customer.cID, cFName, cLName,
book.title,
bookcopies.bkID, bkStatus,
rental.rID, rDateRented
FROM
customer
LEFT JOIN rental
ON customer.cID = rental.rCID
LEFT JOIN bookcopies
ON bookcopies.bkID = rental.rBkID
LEFT JOIN book
ON book.catID = bookcopies.bkCatID
WHERE customer.cFName = 'Gloria' and MONTH (rDateRented) = '1';
Page 24/25
Sunway DIIT Database Fundamental I
6. CONCLUSION
In conclusion, databases make lives a little easier. We learned a lot from completing this
assignment but there is much room for areas of development. Database helps us to maintain
information and data, it is a very efficient if not the best mechanism to store and organize data
for many companies. It allows for a centralized system that can easily be modified anywhere
and anytime, it also allows for convenient sharing among multiple users. Another reason why
databases are so crucial is so that companies can keep up with the massive amounts of
information in a singular place. Furthermore, It is also very easy to understand databases
making it accessible to all new users.
Page 25/25