Sei sulla pagina 1di 19

DATABASE SYSTEM TDB2111 LIBRARY STUDENT ACCOUNT SYSTEM

NAME: i) KUHENTHIRAN A/L MAHALINGAN 1092700321 ii) JEEVANTHIRAN A/L RAGENDRAN 1091103424 iii) PRASHAANTH A/L MATHIALAGAN 1091102093 iv) TEE KANG NAN 1091101927 GROUP: TMB04C TUTOR NAME: ROY CHANG KWANG YANG

As a Database System student,we should done a database to fullfill the project objective. The topic that given to our group is Student Library Account system. This topic will helps the staff in library to enter the data into system more efficiently. Furthermore this system also can be used at all types of library.Users will be more happy and feels comfortable to borrow books from library because they only need to create an account for once. Then, every time when they borrow books, they just need to go to the counter and meet the staff to scan the id ,were the user information will display in system.

Moreover, our system also able to save automatically about user information. It also can delete and update the users information. It will keep the library account system up to date.

This system will basically overcome problems regarding student account system in library such as the users old information. This system can update the users information frequently as users borrows books from library. Furthermore, this system also can arrange the data about the users systematically and efficiently. All data in this system is well organized which makes the staff easy to do their job. Moreover,this system is also can make it easier for staff to delete old data. It makes the system run fast and responsive,so that the users data can be allocate in this system effectively

BUSSINESS RULE

1) EACH LIBRARY HAS MANY STAFF. 2) EACH STAFF HAS AN ACCOUNT. 3) EACH ACCOUNT BELONGS TO ONE STAFF. 4) EACH STUDENT HAS AN ACCOUNT. 5) EACH ACCOUNT BELONGS TO ONE STUDENT. 6) EACH STUDENT CAN BORROW BOOKS. 7) EACH STUDENT CANNOT BORROW MORE THAN 5 BOOKS. 8) EACH BOOK CAN ONLY BE BORROWED BY ONE STUDENT. 9) STUDENT MAY OR MAY NOT BORROW ANY BOOKS.

CONCEPTUAL ER DIAGRAM (CONCEPTUAL MODEL)

1) EACH LIBRARY HAS MANY STAFF. 2) EACH STAFF HAS AN ACCOUNT. 3) EACH ACCOUNT BELONGS TO ONE STAFF.

STAFF
(1,1)

own s

ACCOUNT
(1,1)

4) EACH STUDENT HAS AN ACCOUNT. 5) EACH ACCOUNT BELONGS TO ONE STUDENT.

ACCOUNT
(1,1)

own s

STUDENT
(1,1)

1) 2) 3) 4)

EACH STUDENT CAN BORROW BOOKS. EACH STUDENT CANNOT BORROW MORE THAN 5 BOOKS. EACH BOOK CAN ONLY BE BORROWED BY ONE STUDENT. STUDENT MAY OR MAY NOT BORROW ANY BOOKS.

STUDENT
(0,5)

borro ws (1,N)

BOOK

FULL MODEL

STAFF
(1,1)

own s

ACCOUNT
1 (1,1) (1,1)

own s

N borro ws

(1,1)

BOOK

STUDENT

(1,N)

(0,M)

LOGICAL ER DIAGRAM(INTERNAL MODEL)

1) EACH LIBRARY HAS MANY STAFF. 2) EACH STAFF HAS AN ACCOUNT. 3) EACH ACCOUNT BELONGS TO ONE STAFF.

1
own s

STAFF
(1,1)

ACCOUNT
(1,1)

4) EACH STUDENT HAS AN ACCOUNT. 5) EACH ACCOUNT BELONGS TO ONE STUDENT.

ACCOUNT
(1,1)

own s

STUDENT
(1,1)

1) 2) 3) 4)

EACH STUDENT CAN BORROW BOOKS. EACH STUDENT CANNOT BORROW MORE THAN 5 BOOKS. EACH BOOK CAN ONLY BE BORROWED BY ONE STUDENT. STUDENT MAY OR MAY NOT BORROW ANY BOOKS. 1 M N 1

STUDENT
(1,M) (1,1)

READ
(1,1) (0,N)

BOOK

FULL MODEL

1 own s

STAFF
(1,1)

ACCOUNT
1 (1,1) (1,1)

own s

(1,1)

BOOK

READ

STUDENT

(1,M)

(1,1)

(1,1)

(0,N)

NORMALIZATION

HANDWORK DIAGRAM (DRAWN IN PAPER)

DATA DICTIONARY

TABLE NAME STAFF

ATTRIBUTE NAME

CONTENTS

Type

FORMAT

REQUIRED

PK OR FK PK

FK REFERENCED TABLE

STUDENT

BOOK

ACCOUNT

StaffAccount_ID StaffAccount_Name StaffWorking_date StudentAccount_ID StudentAccount_Na me Student_Phone Student_status Book_ID Book_Name Book_Type Book_Qty Account ref_ID Student account_ID Book_ID Staff account_ID

Staff account number Staff name Staff duty date Student account number Student name Student contact Student status Book Id Book name Type of books Amount of book Account reference id Student account id Book id Staff account id

Int Varchar(20) date Int Varchar(20) Int Varchar(20) Int Varchar(20) Varchar(20) Int Int Int Int int

99999 Xxxxxx 99999999 99999 Xxxxxx 9999999999 Xxxxxx 99999 Xxxxxx Xxxxxx 99999 99999 99999 99999 99999

Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y

PK

PK

PK FK FK FK

STUDENT BOOK STAFF

DDL Scripts

create table Staff( StaffAccount_ID int not null, StaffAccount_Name varchar(20), StaffWorking_date date, primary key (StaffAccount_ID) ); create table Student( StudentAccount_ID int not null, StudentAccount_Name varchar(20), Student_Phone int, Student_status varchar(20), Primary Key (StudentAccount_ID) ); create table Book( Book_ID int not null, Book_Name varchar(20), Book_Type varchar(20), Book_Qty int, BookRental_date date, BookReturn_date date, Book_reorder int, primary key (Book_ID) ); create table Account( AccountRef_ID int not null, StudentAccount_ID int, Book_ID int, StaffAccount_ID int, primary key (AccountRef_ID), foreign key (StudentAccount_ID) references Student, foreign key (Book_ID) references Book, foreign key (StaffAccount_ID) references Staff );

DML Scripts
insert into Staff values(10001,'Jamal','2008-04-21'); insert into Staff values(10002,'Christine','2008-04-22'); insert into Staff values(10003,'Dharshini','2008-04-23'); insert into Staff values(10004,'Anna','2008-04-24'); insert into Staff values(10005,'Ravin','2008-04-25'); insert into Student values(10020,'Ram Rubern','0177991026','Active'); insert into Student values(10030,'Razif','0149312170','Active'); insert into Student values(10040,'Ong Jit Jun','0133377261','Not Active'); insert into Student values(10050,'Shandya','0176136261','Not Active'); insert into Student values(10060,'Hamid','0127263021','Active'); insert into Book values(2010,'Harry Potter','Fiction',4,'2008-04-21','2008-04-28',0); insert into Book values(2011,'Vector Mechanic','NonFiction',10,'2008-04-22','2008-04-29',0); insert into Book values(2012,'Healty Lifestyle','Journal',13,'2008-04-23','2008-04-30',0); insert into Book values(2013,'Grolier','Encyclopedia',8,'2008-04-24','2008-05-01',0); insert into Book values(2014,'The Lords Of Ring','Fiction',20,'2008-04-25','2008-05-02',0); insert into Account values(9001,10020,2010,10001); insert into Account values(9002,10030,2011,10002); insert into Account values(9003,10040,2012,10003); insert into Account values(9004,10050,2013,10004); insert into Account values(9005,10060,2014,10005); reorg table book;

create trigger bookreorder no cascade before update book_qty of on book referencing new as n for each row mode db2sql set n.book_reorder = case when book_qty<10 then 0 when book_qty>=10 then 1 end;

FULL QUARIES
Create db SLAS; Connect to SLAS; create table Staff( StaffAccount_ID int not null, StaffAccount_Name varchar(20), StaffWorking_date date, primary key (StaffAccount_ID) ); create table Student( StudentAccount_ID int not null, StudentAccount_Name varchar(20), Student_Phone int, Student_status varchar(20), Primary Key (StudentAccount_ID) ); create table Book( Book_ID int not null, Book_Name varchar(20), Book_Type varchar(20), Book_Qty int, BookRental_date date, BookReturn_date date, Book_reorder int, primary key (Book_ID) ); create table Account( AccountRef_ID int not null, StudentAccount_ID int, Book_ID int, StaffAccount_ID int, primary key (AccountRef_ID), foreign key (StudentAccount_ID) references Student, foreign key (Book_ID) references Book, foreign key (StaffAccount_ID) references Staff ); insert into Staff values(10001,'Jamal','2008-04-21'); insert into Staff values(10002,'Christine','2008-04-22'); insert into Staff values(10003,'Dharshini','2008-04-23'); insert into Staff values(10004,'Anna','2008-04-24');

insert into Staff values(10005,'Ravin','2008-04-25'); insert into Student values(10020,'Ram Rubern','0177991026','Active'); insert into Student values(10030,'Razif','0149312170','Active'); insert into Student values(10040,'Ong Jit Jun','0133377261','Not Active'); insert into Student values(10050,'Shandya','0176136261','Not Active'); insert into Student values(10060,'Hamid','0127263021','Active'); insert into Book values(2010,'Harry Potter','Fiction',4,'2008-04-21','2008-04-28',0); insert into Book values(2011,'Vector Mechanic','NonFiction',10,'2008-04-22','2008-04-29',0); insert into Book values(2012,'Healty Lifestyle','Journal',13,'2008-04-23','2008-04-30',0); insert into Book values(2013,'Grolier','Encyclopedia',8,'2008-04-24','2008-05-01',0); insert into Book values(2014,'The Lords Of Ring','Fiction',20,'2008-04-25','2008-05-02',0); insert into Account values(9001,10020,2010,10001); insert into Account values(9002,10030,2011,10002); insert into Account values(9003,10040,2012,10003); insert into Account values(9004,10050,2013,10004); insert into Account values(9005,10060,2014,10005); reorg table book;

create trigger bookreorder no cascade before update of book_qty on book referencing new as n for each row mode db2sql set n.book_reorder = case when book_qty<10 then 0 when book_qty>=10 then 1 end;

ENTITIES
Staff

StaffAccount_ID StaffAccount_ID StaffAccount_Name StaffWorking_date

<PK> int not null, varchar(20), date,

Student
Primary Key (StudentAccount_ID) StudentAccount_ID StudentAccount_Name Student_Phone Student_status <PK> int not null, varchar(20), int, varchar(20),

BOOK
primary key (Book_ID) Book_ID Book_Name Book_Type Book_Qty BookRental_date BookReturn_date Book_reorder <PK> int not null, varchar(20), varchar(20), int, date, date, int,

ACCOUNT
primary key (AccountRef_ID) AccountRef_ID StudentAccount_ID Book_ID StaffAccount_ID <PK> int not null, int, int, int,

BIBLIOGRAPHY
1) ONLINE NOTES 2) http://www.w3schools.com/sql/default.asp

3) miscstuff.forumotion.com

APPENDIX

HANDWORK DIAGRAM (DRAWN IN PAPER)

Potrebbero piacerti anche