Dbi202 Project
Dbi202 Project
GROUP 4
ĐẶNG VIỆT ANH | HE151359
TRẦN XUÂN QUANG | HE153654
ĐOÀN HẢI PHONG | HE151364
1. Introduction Problem
a. Describe Problem
Nowaday, libraries were faced with an information explosion and the rapid
growth rate of their collections. The issues confronting library
administrators during that period were mainly physical managements
involving shelving and weeding of materials, storage space, users’ in-
house access to the collection, and preservation of the materials. After our
team researched, the results are as follows:
b. Goal
This database is written to solve the stages and procedures of the library
by retrieving information on the computer without the need for manual
work as before. This helps both library managers and readers easily
control the information of books as well as the return of books in the
library.
2. ER Diagrams and data scheme
a. SET-UP ENTITY – RELATIONSHIP
- Entity
- Weak entity
- Relationship
- Connectivity (force) = 1
- Connectivity = N
-
b. Data Scheme
Publisher(PublisherID, Name, Address, Website, Other)
KindOfBook(BookCode, Category)
Books(BookID, BookCode, PublisherID, Title, AuthorName, Year, Edition,
Quantity, Brief)
Staffs(StaffID, Password, Name, Date_of_birth, Address, Gender, Phone,
Email, Date-started)
Readers(ReaderID, Password, Name, Date_of_birth, Address, Gender,
Email)
Borrowed(BorrowedID, StaffID, ReaderID, Date_start)
BorrowBooks_details(BorrowID,BookID, Quantity, Date_end)
Books_return(BorrowID,Date_return)
Compensation(BorrowedID, Reason)
3.
A.Readers
C.Borrow
E.KindOfBook
This is the entity KindOfBook,this has 2 attributes.Each kind of book have BookCode
as ID of kind (primary key),Category(name of kind).
G.Publisher
I.BorrowBooks details
This is the entity BorrowBooks details(record borrowing book),this has 4
attributes.Each record have BorrowID as ID of record(foreign key from Borrow),
BookID as ID of book(foreign key from Books),Quantity(the amount of book in 1 time
borrow),Date_end(the day return book)
J.Books return
This is the entity Books return(information record about returning book),this has 2
attributes .Each record have BorrowID as ID of record(foreign key from
Borrow),Date_return(the day return book of readers)
Full Diagram
4. SQL command
a. Query using order by
Code :
Test case :
We use ORDER BY to sort the list ascending by informations of staffs
Code :
Test case :
We use INNER JOIN to select book publish in 2018 and its website
Test case :
Code :
Test case :
We use function TOP() to select top 5 with the most number of books
Test case :
We use GROUP BY and HAVING clauses to count staffs manage more than 3
bills
We using subquery to find the most book borrowed by reader and get in into having clause
from Books
A. store procedure
create proc check_Quantity @Book_ID char(10), @NumberofBooks int output
as
begin
set @NumberofBooks = (select Quantity
from Books where BookID = @Book_ID)
end
declare @t int
exec check_Quantity'054JD', @t output
select @t as Quantity
We use procedure to check the quantity of books for which the book's ID is entered
by the librarian or user
A. trigger