Anda di halaman 1dari 5

SRI LANKA INSTITUTE OF INFORMATION TECHNOLOGY

Database Management Systems II (IT202)


Practical Workbook
Year 2 - Semester II 2012

Student Reg. No. Student Name Campus

: : :

Department of Information Technology Faculty of Computing Sri Lanka Institute of Information Technology

Instructions to students: This book must be brought for all the practical classes. The attached grading sheet complete with instructor recommendations must be handed over at the time of the viva. This book consists of three Assignments. Complete the assigned exercises as part of the assignments on a weekly basis. Demonstrate to the lab instructor that the work has been done during each practical session and complete the grading sheet. Otherwise, it will be considered as not attempted in class. All answers should be written by hand. Do not attach printed answers to the book except otherwise state so. A copy of each completed assignment must be uploaded into the course web available at http://moodle.sliit.lk

Laboratory Assignment 1
Session 1-2 Objective: Designing E-ER Models for data requirements.
The requirements for the Academic library are outlined below: Item information The library contains a list of Items Every Item has an item_no, title, and a description Every Item is identified by the item number Items are classified into the following categories: Books, Periodicals, and Software & Manuals Every Book has one or many Authors Every Author has an author_id, last name, first name, and other names. An Author could have written one or many books. Every Periodical has a publisher and a frequency (e.g., daily, weekly, monthly, quarterly and yearly) Every Software & Manuals has a manufacturer and a version Books are further classified as Text Books and Published Books Periodicals are classified into Magazines and Newspapers Every Text Book has a semester, year and section (such as lecture, lab or tutorial) Every Published Book has an edition Published Book has a Published Book Type depending on publisher of the book (for example, same book can be published by different publishers such as US print by McGrawHill and Indian print of the book by TATA McGrawHill) Published Book Type is identified by ISBN number. Also, Published Book Type contains Publisher, Cover (softback or hardback) and Year Published. Periodicals also has a Periodical Type which contains the date the issue was published (for example, November issue of Sports Illustrated). The items, (i.e. Text Book, Published Book Type, Periodical Type and Software & Manuals), can have multiple copies. Each Copy of Item is identified by the access_no. Copy of Item contains a status field which indicates whether the book is borrowed, lost, stolen or available.

Member information There are members of the academic library. Every Member is grouped into different Member_Types (i.e. Senior Lecturer, Lecturer, Assistant Lecturer, Instructor, Administrators, CSD, Guests) Every Member has a library_id (which is unique), last name, first name, other name, phone, location, e-mail, address, password, and remarks

Location contains the campus, floor number, and office number

Loan information Members loan Copy of Items Loan information includes datetime_borrowed, due_date, date_returned, fine, and whether the fine was paid (yes, no) Partial payments are allowed for a fine and each payment has a unique payID, amount and the date paid.

Draw an Extended Entity Relationship (E-ER) diagram for the above mentioned data requirements.

Session 3
Objective: Mapping E-ER Model to Relational Model Use model answer given during the practical session for the library data requirements. Convert the E-ER diagram to relational schema.

Session 4
Objective: Use of normalization to refine the relational schema For the library relational schema (presented in session 3s answer), do the following: 1. Identify the keys for each relation 2. State the functional dependencies for each relation 3. Convert the relational schema to Boyce-Codd Normal Form (BCNF)

Session 5
Objective: DDLs in T-SQL Create the relational schemas in session 4 using T-SQL. Write your script and save your answer as Library.sql file. Use appropriate data types for columns of table. The following constraints exist for the schema. Use appropriate constraint mechanism (such as CHECK constraint, etc.) to enforce the rules stated:

Library Schema: The title attribute of Books, Periodicals and Software_Manuals cannot contain a null value. Ensure that item_no of Books, Periodicals, Software_Manuals start with B, P, S respectively Use IDENTITY property for author_id attribute of Authors table to ensure that a unique id is generated for authors. Ensure that Magazine or Newspaper are the only allowed values for type attribute in Periodicals table. Ensure that the book_section attribute of Text_Books can be only Lecture, Lab, or Tutorial values. Ensure that the year attribute of Text_Books is between 1999 and 3000. Ensure that the cover attribute of Published_Book_Type can only have Soft Cover or Hard Cover values. Ensure that the yr_published attribute of Published_Book_Type is between 1000 and 3000. Ensure that the status attribute of Copy_Item is only Borrowed, Lost, Stolen or Available. Ensure that the library members last name is not null. The default value for datetime_borrowed descriptive attribute of the loan relationship should be the system date.
End of Assignment 1

Anda mungkin juga menyukai