You are on page 1of 6

Database for Developer Assignment

ASSIGNMENT FOR DATABASE WITH MySQL

This assignment like a project which allows students step by step to complete follows
the schedule on Database For Developer module. It will help students how to build and
manipulating a database with MySQL.

Project Name: Book Management System.


Requirements:
Develop a system to manage books, borrow and return information in the library with
the following requirements:
1. Manage book information.
2. Books are categorized as bellow: Algorithms, Programming, Office, System
Analysis and Design, Database, Web, Ecommerce.
3. Manage information of students who will borrow books.
4. Borrow and return information are recorded.
5. Each student can borrows only one book for each category.
6. The maximum duration to loan a book was presumptive.

I. Database Design

1. Identify the entities and the related information for them.


2. Draw a ERD for this system (ERD: Entities Relationship Diagram)

II. Design database and insert data to tables

1. Create a database with name is LibManagement


2. Create tables are described as below:

1
iViettech Education
Professional Programmer Training Center

Books: This table stores book information in the library.

Field Name Data Type Field Size Description


BookID Char 6 The code of book (Category ID + Number ),
Primary Key
Name nVarchar 50 Name of book
Publisher nVarchar 50 Publisher
Author nVarchar 50 Author of books
CategoryID Char 3 Foreign key reference to Categories table
Numofpage Float Long Integer Pages of book
Maxdate Int Long Integer Maximum number of date you can borrow
this book
Num Int Long Integer Number of copy of book in the library
Summary nVarchar 255 Summary the content of book
Picture Varbinary Picture of book

Constraints:
- Numofpage, Maxdate, Num must be >0.

Categories: This table describe category of books.

Field Name Data Type Field Size Description


CategoryID Char 3 Primary Key
Category Name nVarchar 50 Name of category
Moreinfo nVarchar 255 Describe about category

Students: This table describes about students who borrow the books.

Field Name Data Type Field Size Description


CardId Char 8 Number of library card or student card.
(STIT0010 )
Name nVarchar 30 Name of students
Address nVarchar 50 Address of students
Tel Char 10 Phone of students

Receipts: Stores information about borrow and return book.

Field Name Data Type Field Size Description


CardID Char 8 Number of library card or student card.
Reference to Students
BookID Char 6 BookID reference to Books table.
DateBorrow Date/Time Date of borrow
Datereturn Date/Time Date of return
ReturnOK Yes/No

2
92-Quang Trung –Da Namg. Tel: 05113.888 279
Database for Developer Assignment

Constraints:
- Dateborrow: must be small than current date. Default is current date.

3. Create relationships between tables.


4. Input data to tables as below description:

Categories

CategoryID Category Name MoreInfo


CSD Cơ sở dữ liệu Access, Oracle
ECO Ecommerce Sách về thương mại điện tử
GTT Giải thuật Các bài toán mẫu, các giải thuật, cấu trúc dữ liệu
HTT Hệ thống Windows, Linux, Unix
LTT Ngôn ngữ lập trình Visual Basic, C, C++, Java
PTK Phân tích và thiết kế Phân tích và thiết kế giải thuật, hệ thống thông tin v.v..
VPP Văn phòng Word, Excel
WEB Web Javascript, Vbscript,HTML, Flash

Books

BookID Name Publisher Author


CSD001 Cơ sở dữ liệu NXB Giáo dục Ðỗ Trung Tấn
CSD002 SQL Server 7.0 NXB Ðồng Nai Elicom
CSD003 Oracle 8i NXB Giáo dục Trần Tiến Dũng
HTT001 Windows 2000 Professional NXB Giáo dục Anh Thư
HTT002 Windows 2000 Advanced Server NXB Giáo dục Anh Thư
LTT001 Lập trình visual Basic 6 NXB Giáo dục Nguyễn Tiến
LTT002 Ngôn ngữ lập trình c++ NXB Thống kê Tăng Ðình Quý
LTT003 Lập trình Windows bằng Visual c++ NXB Giáo dục Ðặng Văn Ðức
VPP001 Excel Toàn tập NXB Trẻ Ðoàn Công Hùng
VPP002 Word 2000 Toàn tập NXB Trẻ Ðoàn Công Hùng
VPP003 Làm kế toán bằng Excel NXB Thống kê Vu Duy Sanh
WEB00
1 Javascript NXB Trẻ Lê Minh Trí
WEB00
2 HTML NXB Giáo Dục Nguyễn Thị Minh Khoa

CategoryID Numofpage Maxdate Num Summary

3
iViettech Education
Professional Programmer Training Center
CSD 200 3 3 Thiết kế CSDL
CSD 200 3 2 Thiết CSDL và sử dụng SQL Server
CSD 500 5 3 Từng bước sử dụng Oracle
HTT 500 3 2 Sử dụng Windows 2000
HTT 500 5 2 Sử dụng Windows 2000 Server
LTT 600 3 3 Kỹ thuật lập trình Visual Basic
LTT 500 5 3 Hướng dẫn lập trình hướng đối tượng và C++
LTT 300 4 3 Hướng dẫn từng bước lập trình trên Windows
VPP 1000 5 4 Trình bày mọi vấn đề về Excel
VPP 1000 4 3 Trình bày mọi vấn đề về Word
VPP 200 5 2 Trình bày phương pháp làm kế toán
WEB 200 5 2 Từng bước thiết kế Web động
WEB 100 3 2 Từng bước làm quen với WEB

Customers
CardID Name Address Tel
STIT0001 Vy Văn Việt 92-Quang Trung- Đà Nẵng 0511810583
STIT0002 Nguyễn Khánh 92-Quang Trung- Đà Nẵng 0511810583
STIT0003 Nguyễn Minh Quốc 92-Quang Trung- Đà Nẵng 0511810583
STIT0004 Hồ Phước Thoi 92-Quang Trung- Đà Nẵng 0511810583
STIT0005 Nguyễn Văn Định 92-Quang Trung- Đà Nẵng 0511810583
STIT0006 Nguyễn Văn Hải 92-Quang Trung- Đà Nẵng 0511810583
STIT0007 Nguyễn Thị Thuý Hà 92-Quang Trung- Đà Nẵng 0511810583
STIT0008 Đỗ Thị Thiên Ngân 92-Quang Trung- Đà Nẵng 0511810583
STIT0009 Nguyễn Văn A 30- Phan Chu Trinh- Đà Nẵng 0913576890

Receipts
CardID BookID Dateborrow Datereturn Return
STIT000
1 CSD001 30/07/2014   FALSE
STIT000
1 LTT001 30/06/2014 25/07/2014 TRUE
STIT000
2 CSD002 15/08/2014   FALSE
STIT000
2 LTT003 10/08/2014 30/08/2014 TRUE
STIT000
3 WEB001 10/07/2014 20/07/2014 TRUE
STIT000
4 HTT001 10/08/2014   FALSE
STIT000
4 HTT002 20/08/2014 25/08/2014 TRUE
STIT000
6 WEB001 30/08/2014   FALSE
STIT000
6 CSD002 10/08/2014 15/08/2014 TRUE
4
92-Quang Trung –Da Namg. Tel: 05113.888 279
Database for Developer Assignment

STIT000
6 WEB002 15/07/2014 30/07/2014 TRUE
STIT000
7 VPP001 30/08/2014   FALSE
STIT000
7 VPP003 20/08/2014 25/08/2014 TRUE
STIT000
8 VPP001 30/08/2014   FALSE
STIT000
9 CSD001 20/08/2014 23/08/2014 TRUE

III. Simple Queries:

1. List all information of books which is office Category (CategoryID of office


books is “VPP”).
2. List all receipts which are borrowed on August 2014. (CardID, BookID and
borrowdate).
3. List all students who have name start by “N” and borrowed book.
4. List all the students who borrowed book on July 2014 but not return yet.
5. List all information about book name, category name, publisher, author and
number of copy of books in the library.
6. List all receipts which is not return yet and sort the data ascending by borrow
date.
(Name of student, name of book, borrow date)

IV. Complex Queries

1. List total of books follow category. (CategotyID, Category name and total copy
of each category in library).
2. List how many students borrow book on August 2014.
3. List all books which there are number of copy more than number copy of book
have BookID is “LTT001”.
4. List the bookID and number of copy of this in Library (Number of copy in
library = number of copy – number of copy student borrow but not return yet)
5. List all books which have number of borrow greater than number copy of this
book in the library.

V. Other Queries

1. Write a query to create 2 tables with name Borrows (CardID,BooKID,


Dateborrow) and Returns (CardID,BooKID, Datereturn). They are based on
Receipts table.
2. Get all record from Receipts which is not return yet to insert to Borrows table.

5
iViettech Education
Professional Programmer Training Center

VI. View
1. Create a view with a parameter which accept bookid and display number of
copy of this book in the library.
2. Create a view with a parameter to accept a CardID of student and display list of
not return book from this student. (Student name, Book name, Return date).

VII. Store Procedure


1. Create a Stored Procedure to list all book are borrow in current date.
2. Create a Stored Procedure to accept bookID by parameter and display all
students who borrow this book.
3. Create a Stored Procedure to accept input [From date] and [To date] as
parameters then displays number of books which are borrowed in this time.

6
92-Quang Trung –Da Namg. Tel: 05113.888 279

You might also like