Anda di halaman 1dari 14

CS2102 Project Report

Done By:
Chen Yiming Kwan Yann Howe - U058802B Wei Wei - U056973W Wen Zhihao - NT070398M Zhang Yi - NT070332R

Entity Relationship Diagram

Server Details
Web Server: Server Page Language: Database Management System: Zone: Address: Testing: Local Host, Demo: Webhost PHP MySQL Not Used http://cs2102.thiscowispurple.com/

Relational Schema in DDL Code


CREATE TABLE book ( isbn VARCHAR(15) PRIMARY KEY, title VARCHAR(255) NOT NULL, edition INT(11) NOT NULL, price FLOAT NOT NULL, pages INT(11) NOT NULL, LANGUAGE VARCHAR(30) NOT NULL, rank INT(11) NOT NULL, genre TEXT NOT NULL, review TEXT); CREATE TABLE author ( aid INT(11) PRIMARY KEY, name VARCHAR(50) NOT NULL, nationality VARCHAR(50)); CREATE TABLE publisher ( pid INT(11) PRIMARY KEY, pname VARCHAR(50) NOT NULL, addr TEXT, contact TEXT); CREATE TABLE writes ( isbn VARCHAR(15) references book(isbn), aid INT(11) references author(aid)); CREATE TABLE publish ( pid INT(11) references publisher(pid), isbn VARCHAR(15) references book(isbn), YEAR YEAR(4), PRIMARY KEY ( pid,isbn ));

SQL Code
Some of the SQL+PHP used in our project Basic Search

By ISBN:
SELECT b.isbn, b.title, a.name, pr.pname, p.YEAR FROM book b, publisher pr, author a, publish p, writes w WHERE b.isbn = w.isbn AND b.isbn = p.isbn AND w.isbn = p.isbn AND pr.pid = p.pid AND a.aid = w.aid AND b.isbn = $isbn

By Title:
SELECT b.isbn, b.title, a.name, pr.pname, p.YEAR FROM book b, publisher pr, author a, publish p, writes w WHERE b.isbn = w.isbn AND b.isbn = p.isbn AND w.isbn = p.isbn AND pr.pid = p.pid AND a.aid = w.aid AND b.title LIKE '$title'

By Author:
SELECT b.isbn, b.title, a.name, pr.pname, p.YEAR FROM book b,

WHERE

publisher pr, author a, publish p, writes w b.isbn = w.isbn AND b.isbn = p.isbn AND w.isbn = p.isbn AND pr.pid = p.pid AND a.aid = w.aid AND a.name LIKE '$name'

By Publisher:
SELECT b.isbn, b.title, a.name, pr.pname, p.YEAR FROM book b, publisher pr, author a, publish p, writes w WHERE b.isbn = w.isbn AND b.isbn = p.isbn AND w.isbn = p.isbn AND pr.pid = p.pid AND a.aid = w.aid AND pr.pname LIKE '$pname'

Browse by Genre
SELECT b.isbn, b.title, a.name, pr.pname, p.YEAR FROM book b, publisher pr, author a, publish p, writes w WHERE b.isbn = w.isbn AND b.isbn = p.isbn AND w.isbn = p.isbn AND pr.pid = p.pid AND a.aid = w.aid AND b.genre LIKE '%$genre%'

Advanced Search
SELECT b.isbn, b.title, a.name, pr.pname, p.YEAR FROM book b, publisher pr, author a, publish p, writes w WHERE b.isbn = w.isbn AND b.isbn = p.isbn AND w.isbn = p.isbn AND pr.pid = p.pid AND a.aid = w.aid AND b.genre LIKE '%$genre%' AND b.title LIKE '%$title%' AND b.LANGUAGE = '$language' AND p.YEAR BETWEEN '$after' AND '$before'

Add Book
INSERT INTO book VALUES ('$isbn','$title',$edition,'$genre','$language','$pages',$price,$rank, '$review') INSERT INTO author VALUES (aid, '$name', '$nationality') INSERT INTO publisher VALUES ($pid, '$pname', '$addr','$contact) INSERT INTO writes VALUES ($aid,'$isbn') INSERT INTO publish VALUES($pid,'$isbn

Delete Book
DELETE DELETE DELETE INSERT from from from INTO publish where isbn='$isbn' writes where isbn='$isbn' book where isbn='$isbn' publish VALUES($pid,'$isbn',$year)

Update Details
UPDATE book SET title='$title',edition='$edition',genre='$genre',language='$language',pages=' $pages',price='$price',rank='$rank',review='$review' where isbn='$isbn' UPDATE author SET name='$name',nationality='$nationality' where aid='$aid UPDATE publisher SET pname='$pname',addr='$addr' ,contact='$contact' where pid='$pid'"; UPDATE publish SET pid='$newpid', year='$newyear' where isbn ='$isbn' UPDATE writes SET aid='$newaid' where aid='$aid' and isbn ='$isbn

Screen Dumps
Some images of our catalogue Browse

Screen Dumps
Basic Search

Screen Dumps
Basic Search Results

Screen Dumps
Advanced Search

Screen Dumps
Book Information

Screen Dumps
Admin Panel

Notes
Our Goal Our goal is to present our understanding of database design and SQL, not designing a good GUI (using php) for users and administrators to manage the database system. Hence, some features have not been implemented in our user interface, such as searching for author information or publisher information, which is similar to searching the book information which we have presented. The basic search does not include all attributes of the books for the same reason. That said, our design includes all the representative search methods. An assumption we made is that the admin is well trained and seldom makes mistakes when managing the system. Adding books Assume admin is always correct when assign an id to an author and a publisher, which means for different authors or publishers, he will always assign different ids to them. When he adds in a new book with an author or a publisher already in our database, he can just provide the author id or publisher id, and skip the steps of providing the details of the author or the publisher. Deleting Books Only the function of deleting books is provided. Since normally we dont need to delete a publisher or an author in our database and would not be a practical action (ie. deleting every book by a certain publisher). Deleting of relation is not provided. Updating Information The book ISBN, author id and publisher id cannot be modified, they are unchangeable. Therefore the administrator must be familiar with the aid and pid

of the corresponding book ISBN so that he can easily modify the author or publisher of a book. Later on we can improve on this interface by providing more of the books information to the admin and links in the book information to edit the various details instead of a simple form. Conclusion Our catalogue is still rough at the edges as far as the user interface is concerned. This can be fixed with javascript, php and plenty of HTML. However, the main focus of creating and interacting with a database, we believe, has been displayed adequately. Our understanding of the practical uses of a database in real life is very must better after finishing this project.

Anda mungkin juga menyukai