Your SlideShare is downloading. ×
A database design_report_for_college_library final
A database design_report_for_college_library final
A database design_report_for_college_library final
A database design_report_for_college_library final
A database design_report_for_college_library final
A database design_report_for_college_library final
A database design_report_for_college_library final
A database design_report_for_college_library final
A database design_report_for_college_library final
A database design_report_for_college_library final
A database design_report_for_college_library final
A database design_report_for_college_library final
A database design_report_for_college_library final
A database design_report_for_college_library final
A database design_report_for_college_library final
A database design_report_for_college_library final
A database design_report_for_college_library final
A database design_report_for_college_library final
A database design_report_for_college_library final
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

A database design_report_for_college_library final

13,278

Published on

DataBase design for college library

DataBase design for college library

Published in: Technology, Education
0 Comments
6 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
13,278
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
814
Comments
0
Likes
6
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Library Management System Saira Iqbal Concepts on Database L0290KKKK1110 MSc (IT)QP A Database Design for College LibraryAbstractLibrary managment refers to the issues involved in manging the resources available in library suchas classification of material, book processing and borrowing materials. UK market is mature anddifferent systems are employed by the libraries to manage their resources in an efficient manner butstill many libraries remain unconvinced and show reluctance to employ and switch over to newsystemsIn the following sections I will analyse the limitations of existing manual system employed by acollege library and will mainly focus on the solution to provide a centralised repository enabling thelibrary administrator to store, access and process the information when required. A prototype of thedatabase to hold the information will be designed considering the available techniques andmethodologies and then finally the new system prototype will be created in the light ofrecommendations and outcomes of the initial analysis and design. MySQL DBMS will berecommended and used for developing the prototype of the system. I will use relational databasesystem to represent the relation between assets of library and which will shows the data library holds.Report will also include a complete illustration of the final prototype and justification of adopting themethodologies and technologies.
  • 2. Saira Iqbal Page 2 of 19Contents Page Section..............................................................................Page Number 1. Introduction............................................................................3 1.1. Background……………………………………………..3 1.2. Objective………………………………………………..3 1.3. Scope……………………………………………………3 1.4. Technology Used……………………………………….3 2. Types of Library Management Systems………………………3 2.1. Advantages of Computer based Libray system……….3 2.2. Disadvantages…………………………………………..4 3. Legacy and Proposed System…………………………………4 3.1.1.Current System…………………………………………4 3.1.2.Weakness of Current System………………………......4 3.2.0.New System……………………………………………5 3.2.1.Features of Proposed System…………………………..5 4. Literature Review......................................................................5 4.1.Requirement Analysis……………………………………5 5. New System Design………………………………………......6 5.1. Conceptual Data Model (ER Diagram)..…………………6 5.2. Logical Design……………………………………………7 5.3. Normalization………………………………………… .. 12 5.4. Physical Design………………………………………….14 6. Data manipulation Language…………………………….........17 6.1. Funcationality of SQL statements……………………….17 7. Conclusion.................................................................................18 8. Recommendations.....................................................................18 9. References.................................................................................18List of Figures • An entity-relationship diagram of given requirement..............7 • Relational Database………………….……………………….7 • SQL statements and what the statements do……………….. 14 • Set of SQL statements that will provide functionalities……..17
  • 3. Saira Iqbal Page 3 of 191.0 Introduction1.1 BackgroundLibrary database system is designed to maintain the library assets in a suitable way.This report isabout a rational database design of a college library in which members of the library can keep trackon availability of books, information about membership either they are student or staff of college,they can join or leave library and some responsibilities of librarians are added.The core goals of this report are to define the entities, attributes and their relationship to create adatabase that can be easily manage by admin.Following are the facilities:Librarian: can find if the book is available or not its status and how much fine is dueMember: can borrow & return books and can leave and join libraryIn the report the findings describe the deficiency of data keeping method and, which can be increasethe budget to hire manpower. Following these findings, conclusions are drawn and a number ofrecommendations are made as to how to increase the reliability of data, reduce redundancy andaccessibility to data has been made stress-free.1.2 ObjectivesThe objectives of this report are to provide complete database for college library which will help tominimize the duplication of data, get rid from paper filling system and it makes the processing of datavery easy without waste of time.1.3 ScopeThis report examines that any educational system can use it in their libraries to determine about theauthor detail, publisher’s detail, availability of books, can track members record etc. and it is veryeasy to modify by making changes in database. It does not examine online system of library1.4 Technology Used  MYSQL 5.0.0 in wamp server  MS Visio 2010  DeZign for Database V6  MS word 20102.0 Types of Library Management SystemsThere are two types of library management systems; one is old fashioned which is used to keep libraryresource’s detail manually but now a days computrised library systems are used because this is theworld of technology and develompment so people prefered to use computer based systems rather thanmanual.2.1 Advantages of Computer based library management system
  • 4. Saira Iqbal Page 4 of 19  It provides fast tracking of material  Increased Consistency  Reduce workforce to maintain library resources  Less expensive because only once you need to spend money on system  No duplication of records  Occupy less space as for paper based system there should be separate space to keep them  Security of the system by authorizating access to limited people according to their rights2.3 Disadvantages  Risk of hardware or software fauiler  Data can be crashed  Training required to understand the system  It required high conversion cost to transform file-based system into computer based system3.0 Legacy System and Proposed SystemIn this section I will discribe about the legacy system and about the proposed system.3.1 Current SystemExisting system of the library is manual system which has lack of functionalities. As due to largevolume of books and daily based queries system is not comfertable to handle daily transactionproperly.Current system work as i- Membership Students needs to get membership by filling a “new membership form” available in library and provide this form to librarian with deposit of £25 which are refundable at the end of course. ii- Borrow books Students request for books then librarian issues them books first by checking in registers if these books are issued to someone else or not it took so long, once he/she found book, he took book card from the book and write the date of issue and return of book and attached student membership card along with this card after that put in to record register which are sorted by book category wise. Student can hold maximum of nine days one book. iii- Return books When student come to return book the librarian check in a record register the data of issue and date of return of book along with the book card and student card and return the student membership card to student and place book in rack in sorted manner . iv- Fine Calculated If the due date of books is passed then librarian calculated the difference between the issue date of book and return date of book. Fine is considered to be 50 p per day after due date.3.1.1 Current system weaknesses  Difficult to arrange all data in alphabetical order  Take time to find book status  More staff is required to manage library  Expensive
  • 5. Saira Iqbal Page 5 of 19  By in/out process of cards may cause damage to card which create problem to identify which book is issued to which student  Modification of record took so long to find all data in different registers  Loss of assets  Difficult to understand for new employee3.2 New SystemNew features which will be incorporated with database design for library which can handle all queriesregarding library and maintain its assets accordingly.3.2.1 Features of Proposed System  Detail of each student/member is stored in database  Large number of volume of books are easily maintained  List of students with same category can be viewed  List of available books can be viewed  Fine is easily calculated by system automatically  Librarians can add/modify/delete students and books  Can see the list of issued books  List of books not returned on time by entering their id or name of book  Borrowing of book become easy because in database librarian can find in seconds if this is book is issued to someone else or not  Librarians has password and login detail of database so it is secure process4.0 Literature ReviewIt’s a right time to rebuild the library system because as day by day number of students and staff areincreasing in our institute and size of library is also expanding so we need workforce to handle itthat’s why there should be a seamless process which can handle all this pressure in proper way. Atthat point our teacher suggested the creation of relational database system which can manage all theseproblems4.1 Requirement AnalysisOur library database system provides cost effective and efficient procedure to maintain data of library.It needs to store student details because it’s an internal library of college so we don’t need to store anycustomer’s data. We store staff detail, librarian details and available resources i.e. books, journals,cds, racks etc. detail in our database.Students need to register in library to get membership which has limit of one year so at time ofregistration he needs to provide his name, course name, id, DOB and address. A library card can beissued to him after storing details in system.Books has unique number for their identity and category type, author name, publisher name, copynumber etc. and library must have record of which book is issued to which member of library andeither its return on time or not and calculation of fine overdue.When a student borrows a book an entry of his name is entered in database by librarian and returndate is automatically comes up in system. It also shows how many books are issued to one member.They can only borrowed maximum of five books at a time.Before borrowing any book members oflibrary can check if the book is available or not.
  • 6. Saira Iqbal Page 6 of 19Tasks of librarians are following:  Add members  Add library cards and assign them to members  Handle returns  Check fines  Add books/ assets to the database  Remove assets from the database  Receive payments from members and update the fines  View all member’s detail5.0 New System DesignThere are three phases of database system design model, one is conceptual design second is logicaldesign and third is physical model in which data has been placed in database. In our system all thesethree phases have been designed and described accordingly.5.1 Conceptual Design (ER Diagram)“ERD or Entity-relationship model, a graphical representation of entities and their relationships toeach other, typically used in computing in regard to the organization of data within databases”It is cleared from above discussion that main entities of Library are , members (student or staff),books and librarians which store data regarding any queries e.g. how many books are borrowed, finepayable etc. In this diagram we try to show possible entities and their relationship with each other andwhat attributes they hold. Using ER Design redundancy of many items can be reduced and it’s a goodpractice to show relation among entities.Cardinality of the relationship/Multiplicity is described as:An Author can write many books (1:*)A book can have many authors (1:*)A book can have many categories (1:*)A member can be associated with zero or many books borrowed (0:*)A borrowed transaction must only be associated with one and only one member (1:1)Books can have zero or many transactions…… (0: *)Librarian handle transactions…….. (1 :*)Librarian creates membership……. (1 :*)Librarian perform fine transaction… (1 :*)Borrow transactions on fines… (1:0)Members pays fine… ……………… (1:*)
  • 7. Saira Iqbal Page 7 of 19Members can have only one membership……….. (1 :1)logically yes but in database its 1:* because there will be always one activeIdentifying relationship is when child object is dependent on parent object.Shown as dotted line: ---------Non-identifying relationship is when the primary key attributes of the parent must not becomeprimary key attributes of the childDefined as continuous line :In this diagram we can see that entity borrow_transaction is dependent on librarian, books andmembers entities because for every transaction these three requirements are necessary. A librarian canissue books, Librarian provides membership and done transactions on books and can also get finefrom members. Because many transactions can be done on many books at same time we associatebooks with transactions. In this EERD we can see the clear many to many relations of books andauthor and similarly for books and categories entity. This diagram show dependencies of relation andreduce redundancy problems as well.5.2 Logical Design (Relational Database Schema)After ER design of library system we found new relations between entities and try to summarise theminto proper relations (tables):
  • 8. Saira Iqbal Page 8 of 19Entities & their Relationships DetailTable: AuthorColumn name Primary key Data type Not Comment NULLauthor_id {PK} Yes INTEGER Yes Primary Key (author_id)first_name No VARCHAR(40) No First Name of Authorlast_name No VARCHAR(40) No Last Name of AuthorRelationships:Name Relationship Parent Child Cardinality typeauthor_books_by_author Identifying author books_by_author Zero Or MoreTable: BooksColumn name Primary key Data type Not NULL Commentbook_id {PK} Yes INTEGER Yes PRIMARY KEY (book_id)pub_id {FK} No INTEGER No FOREIGN KEY (pub_id) REFERENCES Publisher(pub_id)book_title No VARCHAR(40) No Title of bookedition No VARCHAR(40) No Name of publisheravailability No BOOL No Book available or notnum_of_copies No INTEGER No Quantity of booksstate No VARCHAR(40) No Good,bad,excellentcatalog_number No INTEGER No Rack numberrow_number No INTEGER No Rows in a rackactive No BOOL No Is book stolen, damage or lost then it would be 0 otherwise 1Created_by No VARCHAR(40) No For internal auditing purpose name of librarian who created entry in DBUpdated_by No VARCHAR(40) No For internal auditing purpose name of librarian who updated entry in DBcreated No DATETIME No Date time of creationupdated No DATETIME No Date time of updatingRelationships:Name Relationship Parent Child Cardinality typebooks_books_by_author Identifying books books_by_author Zero Or Morebooks_books_by_category Identifying books books_by_category Zero Or Morebooks_borrow_transaction Non Identifying books borrow_transaction Zero Or MorePublisher_books Non Identifying Publisher books One Or MoreTable: books_by_authorColumn name Primary key Data type Not Comment
  • 9. Saira Iqbal Page 9 of 19 NULLauthor_id Yes INTEGER Yes PK & FOREIGN KEY (author_id) REFERENCES author(author_id)book_id Yes INTEGER Yes PK & FOREIGN KEY (book_id) REFERENCES books(book_id)Relationship:Name Relationship Parent Child Cardinality typeauthor_books_by_author Identifying author books_by_author Zero Or Morebooks_books_by_author Identifying books books_by_author Zero Or MoreTable: books_by_categoryColumn name Primary key Data type Not Comment NULLcategory_id Yes INTEGER Yes PK & FOREIGN KEY (category_id) REFERENCES Categories(category_id)book_id Yes INTEGER Yes PK & FOREIGN KEY (book_id) REFERENCES books(book_id)Relationships:Name Relationship Parent Child Cardinality typebooks_books_by_category Identifying books books_by_category Zero Or MoreCategories_books_by_category Identifying Categories books_by_category Zero Or MoreTable: Borrow_TransactionsColumn name Primary Data type Not Comment key NULLborrow_transaction_id Yes INTEGER Yes PRIMARY KEY (borrow_transaction_id)librarian_id No INTEGER Yes FOREIGN KEY (librarian_id) REFERENCES librarian(librarian_id)book_id No INTEGER Yes FOREIGN KEY (book_id) REFERENCES books(book_id)member_id No INTEGER Yes FOREIGN KEY (member_id) REFERENCES members(member_id)borrowed_datetime No DATETIME No When the book is borrowedreturned_datetime No DATETIME No When the book is returnedborrowed_by No VARCHAR(40) No Who borrowed (name of member)returned_by No VARCHAR(40) No Who returneddate_due No DATE No Due date of book borrowed
  • 10. Saira Iqbal Page 10 of 19is_returned No BOOL No If returned 1 otherwise 0created_by No VARCHAR(40) No For internal auditing purpose name of librarian who created entry in DBUpdated_by No VARCHAR(40) No For internal auditing purpose name of librarian who updated entry in DBcreated No DATETIME No Date time of creationupdated No DATETIME No Date time of updatingRelationships:Name Relationship Parent Child Cardinality typebooks_borrow_transaction Non books borrow_transaction Zero Or More Identifyingborrow_transaction Non borrow_transaction fined_transactions Zero Or One_fined_transactions Identifyinglibrarian_borrow_transaction Non librarian borrow_transaction Zero Or More Identifyingmembers_borrow_transaction Non members borrow_transaction One Or More IdentifyingTable: CategoriesColumn name Primary key Data type Not Comment NULLcategory_id Yes INTEGER Yes PRIMARY KEY (category_id)category_name No VARCHAR(40) No Name of category e.g Science, Crime etcRelationships:Name Relationship Parent Child Cardinality typeCategories_books_by_category Identifying Categories books_by_category Zero Or MoreTable: Fined_TransactionsColumn name Primary Data type Not Comment key NULLfined_transaction_id Yes INTEGER Yes PRIMARY KEY (fined_transaction_id)member_id No INTEGER Yes FOREIGN KEY (member_id) REFERENCES members(member_id)librarian_id No INTEGER Yes FOREIGN KEY (librarian_id) REFERENCES librarian(librarian_id)borrow_transaction_id No INTEGER Yes FOREIGN KEY (borrow_transaction_id) REFERENCES borrow_transaction(borrow_transaction_id)amount_added No VARCHAR(40) No Total Amount Finedamount_received No VARCHAR(40) No Amount received till datenotes No VARCHAR(40) No To add notes
  • 11. Saira Iqbal Page 11 of 19deleted No DATETIME No Date & Time of Deletioncreated No DATETIME No Date & time of transaction creationcreated_by No VARCHAR(40) No For internal auditing purpose name of librarian who created entry in DBRelationship:Name Relationshi Parent Child Cardinality p typeborrow_transaction Non borrow_transaction fined_transactions Zero Or_fined_transactions Identifying Onelibrarian_fined_transactions Non librarian fined_transactions Zero Or Identifying Moremembers_fined_transactions Non members fined_transactions Zero Or Identifying MoreTable: LibrarianColumn name Primary Data type Not Comment key NULLlibrarian_id Yes INTEGER Yes PRIMARY KEY (librarian_id)name No VARCHAR(40) No Librarian Nameuser_name No VARCHAR(40) No User name assigned to librarianpassword No VARCHAR(40) No Password for logincreated_by No VARCHAR(40) No For internal auditing purpose name of librarian who created entry in DBupdated_by No VARCHAR(40) No For internal auditing purpose name of librarian who updated entry in DBcreated No DATETIME No Date time of creationupdated No DATETIME No Date time of updatingactive No BOOL No If librarian is active or notinactive_reason No VARCHAR(40) No Why not activeRelationship:Name Relationship Parent Child Cardinality typelibrarian_borrow_transaction Non Identifying librarian borrow_transaction Zero Or Morelibrarian_fined_transactions Non Identifying librarian fined_transactions Zero Or Morelibrarian_membership Identifying librarian membership Zero Or MoreTable: MembersColumn name Primary Data type Not Comment key NULLmember_id Yes INTEGER Yes PRIMARY KEY (member_id)
  • 12. Saira Iqbal Page 12 of 19external_id No INTEGER Yes ID For library usemember_type No VARCHAR(40) No Either its staff or studentmember_name No VARCHAR(40) No Name of memberphone_number No INTEGER No Contact number of membergender No VARCHAR(40) No Male or Femaleemail No VARCHAR(40) No Email addressactive No BOOL No Active or inactivecreated_by No VARCHAR(40) No For internal auditing purpose name of librarian who created entry in DBupdated_by No VARCHAR(40) No For internal auditing purpose name of librarian who updated entry in DBcreated No DATETIME No Date time of creationupdated No DATETIME No Date time of updatingRelationships:Name Relationship type Parent Child Cardinalitymembers_borrow_transaction Non Identifying members borrow_transaction One Or Moremembers_fined_transactions Non Identifying members fined_transactions Zero Or Moremembers_membership Identifying members membership Exactly OneIn logical design model we can see the all entities, their data types, constraints on them and theirrelations.5.3 NormalizationTables in database are designed to use third normal form (3NF). As we know that to use third normalform our table must satisfy the requirement of first normal form ((1NF) and second normal form(2NF).Most of the tables in database have been designed to keep optimization in mind. We usenormalization to remove update, delete & insert anomalies.I have used the following way to normalize my tables. I have explained only one table here:My books table before normalizationBook_id Book_title Edition Book_category1 Book_category2 Publisher Author_name1NFBy implementing First Normal formal I have to check that there should be no multiple values againstany field of a table and I have to create a separate table for each set of related data with uniqueprimary key. To apply first normal form I make some changes in above table, I separate author_namefield into two fields (first name & last name) and identify book_id as primary_key.Book_id Book_titl Edition Book_category1 Book_category2 Publisher Author_Fname Author_Lname e2NF
  • 13. Saira Iqbal Page 13 of 19For 2nd Normal form the non key attributes should be fully dependent on composite primary key,partial dependency is not allowed.First I created two tables from above tables to associate with repeating group of data and relate themwith foreign key. After this I have to check that each non-key field in the table will be an attribute thatdescribes that Primary KeyBooks TableBook_id Book_titl Edition Book_categories Publisher eAuthor TableBook_id author_fname author_lnameBy using 2NF two tables created books table with books detail but no repeat fields as in 1NF andauthor table associated with books table none of no-key element is partially dependent on primarykey.3NFThe final normalization of my table is 3rd normal form. To achieve this normal form I have toeliminate the non-key values which are not fully functionally dependent on primary key of the table.Author TableAs author name is not directly dependent on book id so a separate table is created for it with its ownprimary key id author_id First_name lastname 11 Denial Shah 12 Iqbal MittalBook_by_author Table:The relationship between book and author table is maintained in book_author table which is many tomany as many a book has many authors and an author can write many books. This relation isestablished by creating a third table book_author which maps book to author and vice versa. Thistable contains two fields both as foreign keys which refer to book and author table respectively toestablish one to many relationship on both sides. Book_id author_id 5001 11 5002 122Books TablePublisher id is used as foreign key.Book_id Book_title Pub_id Edition availability No.of copies state active5001 COD 620 1st yes 10 good 1Same rule is applied for category table as author’s table. The membership is separated from member’stable to avoid functional dependency. And similarly we split publisher table from books table to avoid
  • 14. Saira Iqbal Page 14 of 19data duplication. fined_transactions table is kept separate from borrowed_transactions table in orderto minimize redundancy.5.4 Physical database DesignAfter logical design of database I put data in database to create table and their attributes, I runfollowing queries in MYSQL console:.Add Table “books”------------------------CREATE TABLE `books` ( `book_id` INTEGER NOT NULL, `book_title` VARCHAR(40), `edition` VARCHAR(40), `pub_name` VARCHAR(40), `pub_date` DATE, `availability` BOOL, `num_of_copies` INTEGER, `state` VARCHAR(40), `catalog_number` INTEGER, `row_number` INTEGER, `active` BOOL, `created_by` VARCHAR(40), `update_by` VARCHAR(40), `created` VARCHAR(40), `updated` VARCHAR(40), CONSTRAINT `PK_books` PRIMARY KEY (`book_id`));Add Table “borrow_transaction”------------------------------------------CREATE TABLE `borrow_transaction` ( `borrow_transaction_id` INTEGER NOT NULL, `librarian_id` INTEGER NOT NULL, `book_id` INTEGER NOT NULL, `member_id` INTEGER NOT NULL, `borrowed_datetime` DATETIME, `returned_datetime` DATETIME, `borrowed_by` VARCHAR(40), `returned_by` VARCHAR(40), `date_due` DATE, `is_returned` BOOL, `created_by` VARCHAR(40), `updated_by` VARCHAR(40), `created` VARCHAR(40), `updated` VARCHAR(40), CONSTRAINT `PK_borrow_transaction` PRIMARY KEY (`borrow_transaction_id`));Add Table “librarian”------------------------------
  • 15. Saira Iqbal Page 15 of 19CREATE TABLE `librarian` ( `librarian_id` INTEGER NOT NULL, `name` VARCHAR(40), `user_name` VARCHAR(40), `password` VARCHAR(40), `created_by` VARCHAR(40), `updated_by` VARCHAR(40), `created` VARCHAR(40), `updated` VARCHAR(40), `active` BOOL, `inactive_reason` VARCHAR(40), CONSTRAINT `PK_librarian` PRIMARY KEY (`librarian_id`));Add Table “member”---------------------------CREATE TABLE `members` ( `member_id` INTEGER NOT NULL, `external_id` INTEGER, `member_type` VARCHAR(40), `member_name` VARCHAR(40), `phone_number` INTEGER, `gender` VARCHAR(40), `email` VARCHAR(40), `active` BOOL, `created_by` VARCHAR(40), `updated_by` VARCHAR(40), `created` VARCHAR(40), `updated` VARCHAR(40), CONSTRAINT `PK_members` PRIMARY KEY (`member_id`));Add Table “membership”--------------------------------CREATE TABLE `membership` ( `librarian_id` INTEGER NOT NULL, `member_id` INTEGER NOT NULL, `registred_datetime` DATETIME, `registred_by` VARCHAR(40), `membership_status` BOOL, `membership_expiry_date` DATE, PRIMARY KEY (`librarian_id`, `member_id`));Add Table “fined_transactions”---------------------------------------CREATE TABLE `fined_transactions` (
  • 16. Saira Iqbal Page 16 of 19 `fined_transaction_id` INTEGER NOT NULL, `member_id` INTEGER NOT NULL, `librarian_id` INTEGER NOT NULL, `borrow_transaction_id` INTEGER NOT NULL, `amount_added` VARCHAR(40), `amount_received` VARCHAR(40), `notes` VARCHAR(40), `deleted` VARCHAR(40), `created` VARCHAR(40), `created_by` VARCHAR(40), CONSTRAINT `PK_fined_transactions` PRIMARY KEY (`fined_transaction_id`));Foreign key constraints------------------------------>ALTER TABLE `borrow_transaction` ADD CONSTRAINT `books_borrow_transaction` FOREIGN KEY (`book_id`) REFERENCES `books` (`book_id`);>ALTER TABLE `borrow_transaction` ADD CONSTRAINT `librarian_borrow_transaction` FOREIGN KEY (`librarian_id`) REFERENCES `librarian` (`librarian_id`);>ALTER TABLE `borrow_transaction` ADD CONSTRAINT `members_borrow_transaction` FOREIGN KEY (`member_id`) REFERENCES `members` (`member_id`);>ALTER TABLE `membership` ADD CONSTRAINT `librarian_membership` FOREIGN KEY (`librarian_id`) REFERENCES `librarian` (`librarian_id`);>ALTER TABLE `membership` ADD CONSTRAINT `members_membership` FOREIGN KEY (`member_id`) REFERENCES `members` (`member_id`);>ALTER TABLE `fined_transactions` ADD CONSTRAINT `librarian_fined_transactions` FOREIGN KEY (`librarian_id`) REFERENCES `librarian` (`librarian_id`);>ALTER TABLE `fined_transactions` ADD CONSTRAINT`borrow_transaction_fined_transactions` FOREIGN KEY (`borrow_transaction_id`) REFERENCES `borrow_transaction`(`borrow_transaction_id`);>ALTER TABLE `fined_transactions` ADD CONSTRAINT `members_fined_transactions` FOREIGN KEY (`member_id`) REFERENCES `members` (`member_id`);>ALTER TABLE `author` ADD CONSTRAINT `books_author` FOREIGN KEY (`book_id`) REFERENCES `books` (`book_id`);
  • 17. Saira Iqbal Page 17 of 196.0 Data Manipulation Language (DML)“is a family of computer languages used by computer programs and/or database users to insert, deleteand update data in a database. Currently the most popular data manipulation language is that of SQL,which is used to retrieve and manipulate data in a Relational database.”Following queries are used to insert, update and delete data from database(shown few queries only):INSERT INTO `author` (`author_id`, `first_name`, `last_name`) VALUES (2006, edoh, sanda);INSERT INTO `books` (`book_id`, `pub_id`, `book_title`, `edition`, `availability`, `num_of_copies`,`state`, `catalog_number`, `row_number`, `active`, `created_by`, `update_by`, `created`, `updated`)VALUES (1, 0, COD, 2nd, 1, 10, excellent, 3, 5, 1, saira, saira, 2010-10-12 12:10:03,2010-10-12 12:10:03);INSERT INTO `books_by_author` (`author_id`, `book_id`) VALUES (2006, 3);INSERT INTO `categories` (`category_id`, `category_name`) VALUES (1746, Computing);INSERT INTO `fined_transactions` (`fined_transaction_id`, `member_id`, `librarian_id`,`borrow_transaction_id`, `amount_added`, `amount_received`, `notes`, `deleted`, `created`,`created_by`) VALUES (1, 4, 2, 1, 0, 0, no fine, 2011-02-06, 2011-02-02 10:03:01, saira);UPDATE books SET book_title = MCIP’ WHERE book_id= 3;DELETE from books WHERE book_title =’NE’;6.1 Functionality of SQL StatementsTo fetch available copies of a specific book------------------------------------------------------SELECT (books.num_of_copies- temp.borrowed_books_count ) as available_copiesFROM books LEFT JOIN ( SELECT count(*) as borrowed_books_count FROM borrow_transaction WHERE book_id=1 AND is_returned=0) as tempON books.book_id=1WHERE books.book_id=1;To find books with overdue date------------------------------------------SELECT members.member_name, books.book_title, borrow_transaction.borrowed_datetime,borrow_transaction.date_dueFROM borrow_transactionLEFT JOIN members ON borrow_transaction.member_id=members.member_idLEFT JOIN books ON borrow_transaction.book_id=books.book_idWHERE Date_due <= 2011-02-07 AND is_returned=0Search fine payable against members-----------------------------------------------------
  • 18. Saira Iqbal Page 18 of 19SELECT members.member_id, members.member_name,(sum(amount_added)-sum(amount_received) )payable_amountFROM membersLeft Join fined_transactions ON fined_transactions.member_id = members.member_idgroup by members.member_id having (sum(amount_added)-sum(amount_received) ) > 0Some other functions---------------------------SELECT member_id,librarian_id,amount_added from fined_transactions WHERE amount_added>5;SELECT member_type, member_name from membersWHERE member_type!=student;SELECT member_name,member_type,genderFROM members ORDER BY member_name DESC;SELECT book_title, pub_nameFROM books WHERE pub_name LIKE %william%;7.0 ConclusionThe main conclusion that can be drawn is therefore that using MySQL database system has beendesigned for college library which can be used to store data regarding books, members of library andcan also update, delete and add new records.This database is designed with that flexibility that it can be implemented in any library in future; itcan be modified easily into new technology. We can add as many data as required.8.0 RecommendationsIn the light of these conclusions, I recommend that database should be designed for every library.We should established online library system by using this database design at backendIn addition, continue to investigate new languages for database design so that a better access todatabase resources would be happen in future.9.0 ReferencesEntity Relationship diagramURL: http://www.webopedia.com/TERM/E/entity_relationship_diagram.html [webopedia 2010]Academic Report Writing TemplateURL: http://www2.elc.polyu.edu.hk/CILL/reports.htm [CILL 2010]Data Manipulation LanguageURL : http://en.wikipedia.org/wiki/Data_Manipulation_Language [wikipedia 2011]Concepts on database
  • 19. Saira Iqbal Page 19 of 19URL: http://www.dybowski.org/stm/cod [COD 2010]

×