














Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Assignment of Database Design , Full
Typology: Assignments
1 / 22
This page cannot be seen from the preview
Don't miss anything!















ASSIGNMENT 2 FRONT SHEET
P2 P3 P4 P5 M2 M3 M4 M5 D2 D
ASSIGNMENT 2 BRIEF
Update………………………………………………………………………………. Delete……………………………………………………………………………...... P4 Test the system against user and system requirements…………………….. P5 Produce technical and user documentation………………………………...…. Reference………………….……………………………………………………………… ANSWER P2.Develop the database system with evidence of user interface, output and data validations, and querying across multiple tables.
Borrow BorrowID StudentId StaffID BorrowDay
Staff StaffID StaffName StaffPhone StaffAddress Student StudentID StudentName StudentClass StudentPhone Book BookID BookName AuthorID Price TypeID Status BorrowDetail BorrowID BookID Quantity Status Author AuthorID AuthorName AuthorAddress AuthorBiography Type of book TypeID (^) Book Type Name
create database Library go use Library go
Create table Student( studentID varchar( 9 ) primary key not null, studentName varchar( 30 ) not null, studentClass varchar( 10 ) not null, studentPhone int not null, studentAddress varchar( 50 ), ); Create table Staff( staffID varchar( 9 ) primary key not null, staffName varchar( 30 ) not null, staffPhone int not null, staffAddress varchar( 50 ), ); Create table Borrow( borrowID varchar( 8 ) primary key not null, studentID varchar( 9 ) not null, staffID varchar( 9 ) not null, borrowDay date not null, returnDay date not null, foreign key (studentID) references Student,
values('AUT73192', 'Joanne Rowling', 'Yate , United of Kingdom', 'Author of the series Harry Potter'); insert into Author(authorID, authorName, authorAddress, authorBiography) values('AUT73191', 'Stephen King', 'USA', 'The King of Horror has more 350M sold worldwide'); insert into Author(authorID, authorName, authorAddress, authorBiography) values('AUT73190', 'Sandra Cisneros', 'Mexico, USA', 'The voice of women of color in the literary flow'); insert into Author(authorID, authorName, authorAddress, authorBiography) values('AUT73189', 'Charles Dickens', 'Portsmouth , United of Kingdom', 'The most famous writer of the Queen Victoria era.'); insert into Author(authorID, authorName, authorAddress, authorBiography) values('AUT73188', 'Eric Arthur Blair', 'United of Kingdome', 'One admired English nibs of the 20th century'); insert into Author(authorID, authorName, authorAddress, authorBiography) values('AUT73187', 'Pham Huy Hoang', 'Viet Nam', 'He is a developer'); insert into Author(authorID, authorName, authorAddress,authorBiography) values('AUT73186', 'Steven Levy', 'America', 'An journalist has written books about IT.'); go
---------------- Insert data into Type_of_Book table ------------------- insert into Type_of_Book(typeID, bookTypeName) values('TYPE1234', 'Adventure'); insert into Type_of_Book(typeID, bookTypeName) values('TYPE1235', 'Horror'); insert into Type_of_Book(typeID, bookTypeName) values('TYPE1236', 'Science-fiction'); insert into Type_of_Book(typeID, bookTypeName) values('TYPE1237', 'History'); insert into Type_of_Book(typeID, bookTypeName) values('TYPE1238', 'Short story'); insert into Type_of_Book(typeID, bookTypeName) values('TYPE1239', 'Bildungsroman'); insert into Type_of_Book(typeID, bookTypeName) values('TYPE1240', 'Novel'); insert into Type_of_Book(typeID, bookTypeName) values('TYPE1241', 'Political satire'); insert into Type_of_Book(typeID, bookTypeName) values('TYPE1242', 'Dystopian'); insert into Type_of_Book(typeID, bookTypeName) values('TYPE1243', 'Non-fiction');
go
---------------- Insert data into Book table ----------------- insert into Book(bookID, bookName, authorID, typeID, price, [status]) values('BOK12345', 'Harry Potter va hon da phu thuy', 'AUT73192', 'TYPE1234', '40', 'False'); insert into Book(bookID, bookName, authorID, typeID, price, [status]) values('BOK12346', 'Harry Potter va phong chua bi mat', 'AUT73192', 'TYPE1234', '30', 'False'); insert into Book(bookID, bookName, authorID, typeID, price, [status]) values('BOK12347', 'Harry Potter va chiec coc lua', 'AUT73192', 'TYPE1234', '30', 'True'); insert into Book(bookID, bookName, authorID, typeID, price, [status]) values('BOK12348', 'Harry Potter va hoang tu lai', 'AUT73192', 'TYPE1234', '50', 'False'); insert into Book(bookID, bookName, authorID, typeID, price, [status]) values('BOK12349', 'Carrie', 'AUT73191', 'TYPE1235', '55', 'True'); insert into Book(bookID, bookName, authorID, typeID, price, [status]) values('BOK12350', 'The dark tower', 'AUT73191', 'TYPE1235', '60', 'False'); insert into Book(bookID, bookName, authorID, typeID, price, [status]) values('BOK12351', 'The institute', 'AUT73191', 'TYPE1236', '40', 'True'); insert into Book(bookID, bookName, authorID, typeID, price, [status]) values('BOK12352', 'The shining', 'AUT73191', 'TYPE1235', '37', 'True'); insert into Book(bookID, bookName, authorID, typeID, price, [status]) values('BOK12353', 'The house on mange street', 'AUT73190', 'TYPE1237', '20', 'True'); insert into Book(bookID, bookName, authorID, typeID, price, [status]) values('BOK12354', 'Woman Hollering Creek and Other Stories', 'AUT73190', 'TYPE1238', '20', 'True'); insert into Book(bookID, bookName, authorID, typeID, price, [status]) values('BOK12355', 'David Copperfield', 'AUT73189', 'TYPE1239', '30', 'True'); insert into Book(bookID, bookName, authorID, typeID, price, [status]) values('BOK12356', 'The Pickwick Papers', 'AUT73189', 'TYPE1240', '25', 'False'); insert into Book(bookID, bookName, authorID, typeID, price, [status]) values('BOK12357', 'A Tale of Two Cities', 'AUT73189', 'TYPE1237', '15', 'False'); insert into Book(bookID, bookName, authorID, typeID, price, [status]) values('BOK12358', 'Great Expectations', 'AUT73189', 'TYPE1237', '30', 'False'); insert into Book(bookID, bookName, authorID, typeID, price, [status]) values('BOK12359', 'Animal Farm', 'AUT73188', 'TYPE1241', '25', 'True'); insert into Book(bookID, bookName, authorID, typeID, price, [status]) values('BOK12360', 'Nineteen Eighty-Four', 'AUT73188', 'TYPE1242', '33', 'False'); insert into Book(bookID, bookName, authorID, typeID, price, [status]) values('BOK12361', 'Homage to Catalonia', 'AUT73188', 'TYPE1243', '22', 'True'); go
insert into borrowDetail(borrowID, bookID, quantity, [status]) values('BOR98758', 'BOK12357', '1', 'False'); insert into borrowDetail(borrowID, bookID, quantity, [status]) values('BOR98757', 'BOK12351', '1', 'True'); insert into borrowDetail(borrowID, bookID, quantity, [status]) values('BOR98756', 'BOK12360', '1', 'False'); insert into borrowDetail(borrowID, bookID, quantity, [status]) values('BOR98755', 'BOK12358', '1', 'False'); go
---------------- Insert data into Student table --------------------- insert into Student(studentID, studentName, studentClass, studentPhone, studentAddress) values ('GCS091979', 'Nguyen Ngo Minh Tien','GCS0805','0945354419','128/24 Cau Kinh , kp4'); insert into Student(studentID, studentName, studentClass, studentPhone, studentAddress) values ('GCS091978', 'Le Van Sang','GCS0801','0919785423','65/85 Nguyen Trai'); insert into Student(studentID, studentName, studentClass, studentPhone, studentAddress) values ('GCS091977', 'Nguyen Tuan Anh', 'GCS0804','0919919378','23/94 Tran Hung Dao'); insert into Student(studentID, studentName, studentClass, studentPhone, studentAddress) values ('GCS091976', 'Le Quang Ngoc', 'GCS0802', '0919919377','12/74 Aqours'); insert into Student(studentID, studentName, studentClass, studentPhone, studentAddress) values ('GCS091975', 'Dinh Thi Van Tho', 'GCS0805', '0919919379', 'Duong so 1,quan binh tan'); insert into Student(studentID, studentName, studentClass, studentPhone, studentAddress) values ('GCS091974', 'Nguyen Thi Thuy Trang', 'GCS0801', '0966003678', 'Tran Van Giau, quan binh tan'); insert into Student(studentID, studentName, studentClass, studentPhone, studentAddress) values ('GCS091973', 'Nguyen Thi Thu Oanh', 'GCS0804', '0966003679', 'Binh Chanh'); insert into Student(studentID, studentName, studentClass, studentPhone, studentAddress) values ('GCS091972', 'Quach Dieu Huong', 'GCS0805', '0966003680', 'Ha Noi'); insert into Student(studentID, studentName, studentClass, studentPhone, studentAddress) values ('GCS091971', 'Dinh Nhu Thanh', 'GCS0805', '0945354420', 'Duong so 1, quan binh tan'); insert into Student(studentID, studentName, studentClass, studentPhone, studentAddress) values ('GCS091970', 'Ho Nguyen Nguyen', 'GCS0805', '0933006489', '5/10 Cau Kinh'); insert into Student(studentID, studentName, studentClass, studentPhone, studentAddress) values ('GBS084569', 'Nguyen Hong Dan', 'GBS0605', '0951753491', '95/75 Nijisaki'); insert into Student(studentID, studentName, studentClass, studentPhone, studentAddress) values ('GBS084568', 'Phan Thanh Dat', 'GBS0604', '0951753490', '65/91 Aqours'); insert into Student(studentID, studentName, studentClass, studentPhone, studentAddress) values ('GBS084567', 'Nguyen Quoc Viet', 'GBS0603', '0954369728', '128/2c Cau Kinh'); insert into Student(studentID, studentName, studentClass, studentPhone, studentAddress) values ('GBS084566', 'Tran Nguyen Tap', 'GBS0601', '0954369722', '258/12/64/95 Saint snow'); insert into Student(studentID, studentName, studentClass, studentPhone, studentAddress) values ('GBS084565', 'Nghiem Thi Huong', 'GBS0603', '0954369720', '213/46 Azalea'); insert into Student(studentID, studentName, studentClass, studentPhone, studentAddress) values ('GBS084564', 'Nguyen Dat Thinh', 'GBS0602', '0934587291', '74/12/5/9 Printempt'); insert into Student(studentID, studentName, studentClass, studentPhone, studentAddress) values ('GBS084563', 'Truong Quang Duy Thinh', 'GBS0601', '0911234584', '12/23/34/45/ BiBi'); insert into Student(studentID, studentName, studentClass, studentPhone, studentAddress) values ('GBS084562', 'Huynh Thanh Hiep', 'GBS0602', '0258741369', '98/87/76/54/2 Han Mac Tu'); insert into Student(studentID, studentName, studentClass, studentPhone, studentAddress) values ('GBS084561', 'Dang Dong Vi', 'GBS0604', '0258741368', '1234/5678 Nguyen Hue');
insert into Student(studentID, studentName, studentClass, studentPhone, studentAddress) values ('GBS084560', 'Nguyen Anh Thu', 'GBS0605', '0258746980', '25/52 Lily white'); insert into Student(studentID, studentName, studentClass, studentPhone, studentAddress) values ('GDS073687', 'Kotori Minami', 'GDS0404', '0120919960', '12/9 Printemp'); insert into Student(studentID, studentName, studentClass, studentPhone, studentAddress) values ('GDS073686', 'Honoka Kousaka', 'GDS0404', '0030819960', '3/8 Printemp'); insert into Student(studentID, studentName, studentClass, studentPhone, studentAddress) values ('GDS073685', 'Umi Sonoda', 'GDS0404', '0150319960', '15/3 Lily white'); insert into Student(studentID, studentName, studentClass, studentPhone, studentAddress) values ('GDS073684', 'Maki Nishikino', 'GDS0402', '0190419960', '19/4 Bibi'); insert into Student(studentID, studentName, studentClass, studentPhone, studentAddress) values ('GDS073683', 'Rin Hoshizora', 'GDS0402', '0021119950', '2/11 Lily white'); insert into Student(studentID, studentName, studentClass, studentPhone, studentAddress) values ('GDS073682', 'Hanayo Koizumi', 'GDS0402', '0150119960', '15/1 Printemp'); insert into Student(studentID, studentName, studentClass, studentPhone, studentAddress) values ('GDS073681', 'Eli Ayase', 'GDS0405', '0281019950', '28/10 BiBi'); insert into Student(studentID, studentName, studentClass, studentPhone, studentAddress) values ('GDS073680', 'Nico Yazawa', 'GDS0405', '0160719950', '16/7 BiBi'); insert into Student(studentID, studentName, studentClass, studentPhone, studentAddress) values ('GDS073679', 'Nozomi Tojo', 'GDS0405', '0090619950', '9/6 Lily white'); insert into Student(studentID, studentName, studentClass, studentPhone, studentAddress) values ('GDS073678', 'Hanamaru Kunikida', 'GDS0401', '0120032001', '12/03 CYaron'); go
---------------- Insert data into Staff table ---------------- insert into Staff(staffID, staffName, staffPhone, staffAddress) values ('NIJ123987', 'Setsuna Yuki', '0951753640', '546/9 Fuji'); insert into Staff(staffID, staffName, staffPhone, staffAddress) values ('NIJ123986', 'Kasumi Nakasu', '0951753641', '545/10 Fuji'); insert into Staff(staffID, staffName, staffPhone, staffAddress) values ('NIJ123985', 'Ayumu Uehara', '0951753642', '544/11 Fuji'); insert into Staff(staffID, staffName, staffPhone, staffAddress) values ('NIJ123984', 'Shizuku Ousaka', '0951753643', '543/12 Fuji'); insert into Staff(staffID, staffName, staffPhone, staffAddress) values ('NIJ123983', 'Karin Asaka', '0951753642', '542/13 Fuji'); insert into Staff(staffID, staffName, staffPhone, staffAddress) values ('NIJ123982', 'Ai Miyashita', '0951753641', '541/14 Fuji'); insert into Staff(staffID, staffName, staffPhone, staffAddress) values ('NIJ123981', 'Kanata Konoe', '0951753640', '540/15 Fuji'); insert into Staff(staffID, staffName, staffPhone, staffAddress) values ('NIJ123980', 'Emma Verde', '0951753639', '539/16 Fuji'); insert into Staff(staffID, staffName, staffPhone, staffAddress) values ('NIJ123979', 'Rinna Tennouji', '0951753638', '538/16 Fuji'); insert into Staff(staffID, staffName, staffPhone, staffAddress) values ('QUE123456', 'Lanzhu Zhong', '0987654321', '123/45 Hong Kong'); go
2/ Update
update Student SET studentName='Long' Where studentID='GBS084560'
After: 3/Delete
Delete Staff Where StaffName='Rinna Tennouji' Before:
After: P4 Test the system against user and system requirements.
**P5 Produce technical and user documentation ---Showbook Procedure--- Create procedure Showbook AS Begin select from Book End ---ShowStudent Procedure--- Create procedure ShowStudent AS Begin select from Student End ---Show Book Fee Procedure--- Create procedure Fee AS Begin select Book.BookName, Book.Price from Book, borrowDetail where borrowDetail.bookID = Book.bookID; End ---Show Borrowed Detail Procedure--- Create procedure ShowBorrowInformationOf
AS Begin select Borrow.BorrowID, Borrow.borrowDay, Student.StudentName, Staff.StaffName, Book.BookName, Book.Price, borrowDetail.quantity from Borrow, Student, Staff, Book, borrowDetail where Borrow.borrowID = borrowDetail.borrowID and borrow.studentID = Student.studentID and Borrow.staffID = Staff.staffID and borrowDetail.bookID = Book.bookID; End