11
1 (Autonomous) Shamshabad-501218, Hyderabad COMPUTER SCIENCE AND ENGINEERING B.TECH IV SEMESTER 2013 2014 Date: 31 December, 2013 Course Code : A1512 Course Title : DATABASE MANAGEMENT SYSTEMS LABORATORY Course Structure : Lectures Tutorials Practicals Credits - - 3 2 Course Coordinator : Mr R Madan Mohan Team of Instructors : Mrs. A Angel Mary and Mr.A Krishna Chaitanya 1. LABORATORY OVERVIEW: This Laboratory introduces techniques required in the design and implementation of database systems. This Laboratory focuses on relational database management systems, including database design theory: E-R modeling, data definition and manipulation languages, database security and administration. It also covers various database programming concepts such as: Transaction Processing, Concurrency Control and Recovery and various types of databases like distributed database, and intelligent database, Client/Server. 2. OBJECTIVES: The main objectives of this Database Management Systems laboratory are: To provide a sound introduction to the discipline of database management as a Subject in its own right, rather than as a compendium of techniques and product- Specific tools. To familiarize the participant with the nuances of database environments towards an information-oriented data-processing oriented framework To give a good formal foundation on the relational model of data to present SQL and procedural interfaces to SQL comprehensively To give an introduction to systematic database design approaches covering Conceptual design, logical design and an overview of physical design To motivate the participants to relate all these to one or more commercial product environments as they relate to the developer tasks To present the concepts and techniques relating to query processing by SQL Engines To introduce the concepts of transactions and transaction processing To present the issues and techniques relating to concurrency and recovery in Multi-user database environments

COMPUTER SCIENCE AND ENGINEERING - Yolavardhamancse.yolasite.com/resources/4th DBMS LAB MANUAL.pdf · 1 (Autonomous) Shamshabad-501218, Hyderabad COMPUTER SCIENCE AND ENGINEERING

Embed Size (px)

Citation preview

Page 1: COMPUTER SCIENCE AND ENGINEERING - Yolavardhamancse.yolasite.com/resources/4th DBMS LAB MANUAL.pdf · 1 (Autonomous) Shamshabad-501218, Hyderabad COMPUTER SCIENCE AND ENGINEERING

1

(Autonomous) Shamshabad-501218, Hyderabad

COMPUTER SCIENCE AND ENGINEERING

B.TECH IV SEMESTER

2013 – 2014 Date: 31 December, 2013

Course Code : A1512

Course Title : DATABASE MANAGEMENT SYSTEMS LABORATORY

Course Structure : Lectures Tutorials Practicals Credits

- - 3 2

Course Coordinator : Mr R Madan Mohan

Team of Instructors : Mrs. A Angel Mary and Mr.A Krishna Chaitanya

1. LABORATORY OVERVIEW:

This Laboratory introduces techniques required in the design and implementation of database systems. This Laboratory focuses on relational database management systems, including database design theory: E-R modeling, data definition and manipulation languages, database security and administration. It also covers various database programming concepts such as: Transaction Processing, Concurrency Control and Recovery and various types of databases like distributed database, and intelligent database, Client/Server.

2. OBJECTIVES:

The main objectives of this Database Management Systems laboratory are:

To provide a sound introduction to the discipline of database management as a

Subject in its own right, rather than as a compendium of techniques and product-

Specific tools.

To familiarize the participant with the nuances of database environments towards

an information-oriented data-processing oriented framework

To give a good formal foundation on the relational model of data to present SQL and

procedural interfaces to SQL comprehensively

To give an introduction to systematic database design approaches covering

Conceptual design, logical design and an overview of physical design

To motivate the participants to relate all these to one or more commercial product

environments as they relate to the developer tasks

To present the concepts and techniques relating to query processing by SQL

Engines

To introduce the concepts of transactions and transaction processing

To present the issues and techniques relating to concurrency and recovery in

Multi-user database environments

Page 2: COMPUTER SCIENCE AND ENGINEERING - Yolavardhamancse.yolasite.com/resources/4th DBMS LAB MANUAL.pdf · 1 (Autonomous) Shamshabad-501218, Hyderabad COMPUTER SCIENCE AND ENGINEERING

2

3. OUTCOMES:

After completion of the course students will be able to

Understand, appreciate and effectively explain the underlying concepts of database

technologies

Design and implement a database schema for a given problem-domain

Normalize a database

Populate and query a database using SQL DML/DDL commands.

Declare and enforce integrity constraints on a database using a state-of-the-art

RDBMS

Programming PL/SQL including stored procedures, stored functions, cursors, packages.

4. LIST OF EXPERIMENTS:

Week Program Category

List of Programs

1 Practice

sessions on Data

Definition

Language (DDL)

Commands and

Data

Manipulation

Language (DML)

commands in

RDBMS

a) Create a table called Employ with the following structure.

Name Type

empno Number(6)

ename VARCHAR2(20)

Job VARCHAR2(20)

MGR NUMBER(4)

SAL NUMBER(7,2)

b) Add a column commission to the Employ table ‘deptno’, numeric null allowed.

c) Modify the column width of the job field of Employ table. d) Create dept table with the fields deptno,dname,loc. e) Add constraints to the Employ table that empno as the primary key

and f) deptno as the foreign key. g) Add constraints to the Employ table to check the empno value while

entering (i.e) empno > 100. h) Add columns Dob to the Employ table i) Add and drop a column bloodgroup to the Employ table j) Customer table

Name Data type

CUST_NAME VARCHAR2(15)

CUST_STREET VARCHAR2(15)

CUST_CITY VARCHAR2(15)

k) Add customer salary column to the above table? l) Branch table

Name Data type

BRANCH_NAME VARCHAR2(15)

BRANCH_CITY VARCHAR2(15)

ASSERTS NUMBER(15)

Increase the size of data type for asserts to the above branch table?

Page 3: COMPUTER SCIENCE AND ENGINEERING - Yolavardhamancse.yolasite.com/resources/4th DBMS LAB MANUAL.pdf · 1 (Autonomous) Shamshabad-501218, Hyderabad COMPUTER SCIENCE AND ENGINEERING

3

m) Consider the dept table

NAME DATATYPE

DEPTNO NUMBER(2)

DNAME VARCHAR2(15)

LOCATION VARCHAR2(15)

Insert 5 records into dept table n) Create the following emp table

Name Type

empno Number(6)

ename VARCHAR2(20)

Job VARCHAR2(20)

MGR NUMBER(4)

SAL NUMBER(7,2)

o) Add to dept one row at a time using the insert into syntax p) Update the emp table to set the default commission of all

employees to Rs1000/- who are working as managers q) Create a pseudo table employee with the same structure as the

table emp and insert rows into the table using select clauses r) Delete the employee whose empno is 7599. s) List the records in the emp table order by salary in ascending order t) Display only those employees whose deptno is 30. u) Calculate the square root of salary of all employees. v) Count the total records in the EMP table. w) Calculate the total and average salary amount of EMP table. x) Determine the max and min salary and rename the column as

max_salary and min_salary. y) List the records of EMP table grouped by deptno. z) Display the month name of date “12-jan-98” in full.

2 Practice

sessions on Data

Control

Language (DCL)

commands and

Integrity

Constraints

a) Insert the any three records in the emp table as shown below and use rollback? Check the result?

Name Type

empno Number(6)

ename VARCHAR2(20)

Job VARCHAR2(20)

MGR NUMBER(4)

SAL NUMBER(7,2)

b) Insert the any three records in the dept table shown below and use commit? Check the result?

NAME DATATYPE

DEPTNO NUMBER(2)

DNAME VARCHAR2(15)

LOCATION VARCHAR2(15)

c) Insert the any three records in the above dept table and use save point? Check the result?

d) For the dept table, insert 3 rows with with deptno values as 1,2 & 3 and display the table?

e) Delete one row with deptno=3 from dept table and display the table. Now use undo the changes by using appropriate command.

f) Delete one row with deptno=3 from dept table and display the table.

Page 4: COMPUTER SCIENCE AND ENGINEERING - Yolavardhamancse.yolasite.com/resources/4th DBMS LAB MANUAL.pdf · 1 (Autonomous) Shamshabad-501218, Hyderabad COMPUTER SCIENCE AND ENGINEERING

4

Now use commit and check the table contents. g) Create a table called EMP with the following structure

NAME TYPE

EMPNO NUMBER(6)

ENAME VARCHAR2(15)

JOB VARCHAR2(15)

MGR NUMBER(4)

DEPTNO NUMBER(2)

SAL NUMBER(7,2)

Allow NULL for all columns except ename and job. h) Consider dept table

Name Data type

DEPT NO NUMBER(2)

DNAME VARCHAR2(15)

LOCATION VARCHAR2(15)

Add primary constraint to DEPTNO i) Add constraints to the emp table that empno as the primary key and

deptno as the foreign key? j) Add constraints to the emp table to check the empno value while

entering(i.e) empno >100 k) Add constraints to the emp table to check the empno value while

entering (i.e) empno > 100. l) Issue a query to find all the employees who work in the same job as

jones m) Issue a query to display information about employees who earn

more than any employee in dept 30. n) Display the employees who have the same job as jones and whose

salary >= fords. o) Write a query to display the name and job of all employees in dept

20 who have a job that Someone in the Management dept as well as write a query that would display the empname, job where each employee works and the name of their dept

p) Write a query to list the employees having the same job as employees located in ‘ main block’.(use multiple sub query)

3 Practice

Sessions on

Group by

clause, Having

clause, order by

clause and Built

in functions in

RDBMS

a) Create the following table: ENAME DEPTNO SAL adams 20 1100 allen 30 1600 blake 30 2850 clark 10 2450 Ford 20 3000 james 30 950 jones 20 2975 King 10 5000 martin 30 1250 miller 10 1300 scott 20 3000

b) By using the group by clause, display the enames who belongs to deptno 10 along with average salary.

c) Display the average monthly salary bill for each deptno?

Page 5: COMPUTER SCIENCE AND ENGINEERING - Yolavardhamancse.yolasite.com/resources/4th DBMS LAB MANUAL.pdf · 1 (Autonomous) Shamshabad-501218, Hyderabad COMPUTER SCIENCE AND ENGINEERING

5

d) Show the average salary for all departments employing more than two people?

e) Display only these ename of employees where the maximum salary is greater than or equal to 5000?

f) Display lowest paid employee details under each department? g) Display number of employees working in each department and their

department number h) Using built in functions, Display number of employees working in

each department and their department name from dept table. Insert deptname to dept table and insert deptname for each row, do the required thing specified above.

i) Show that value returned by sign(n) function? j) How many days between day of birth to current date? k) Show that two substring as single string? l) List all employee names, salary and 15% rise in salary. m) List all employees which start with either B or C. n) Display lowest paid employee details under each manager

4 Practice

Sessions on

Relational

operators, SQL

operators, SET

operators,

Views, Joins

a) Display all the details of the records whose employee name starts with ‘S’.

b) Select all employees from department numbers 10,20 c) Display all the details of the records whose employee name starts

with ‘E’. d) Display all the details of the records whose employee name does not

starts with ‘S’. e) Display the rows whose empno ranges from 7500 to 7600. f) Display the rows whose empno not in range from 7500 to 7600. g) Calculate the square root of the salary of all employees h) List all employee names and their manager whose dept no is 20 or

30. i) Consider the two tables: EMP_MSTR(EMP_NO, FNAME, MNAME,

LNAME, DEPT, DESIG, BRANCH_NO) and BRACH_MSTR(NAME, BRANCH_NO). Using joins, Write Queries for the following:

1. List the employee details along with branch names to which they belong.(use inner join)

2. List the employees belongs to multiple branches. j) Create a view called customers on the CUST_MSTR table. k) Create a view called Employees on the EMP_MSTR table. l) Write query for inserting data into view created Employees. m) Write query for removing a row where employee name is Raju from

view Employees. n) Write a Query for updating view table Employee where employ

name should be changed to Raghu if nominee_no is 100. o) Consider a Reebok sales company which supplies various items to

various cities. Create a view that contains the items that costs less than the average price for items. Query the view and show the result?

p) Create a view that calculates the total cost of each sale by considering price and quantity of each bought item (to be used for charging customer accounts). The view should return the transaction number and total cost. Query the view and show the result.

Page 6: COMPUTER SCIENCE AND ENGINEERING - Yolavardhamancse.yolasite.com/resources/4th DBMS LAB MANUAL.pdf · 1 (Autonomous) Shamshabad-501218, Hyderabad COMPUTER SCIENCE AND ENGINEERING

6

5 Entity Relationship diagrams: Description 1: Construct an Entity-Relationship diagram for the following situation: A company consists of several dept, each having a number of employees. Each dept has a manager who must be on the monthly payroll. Other employees are on either the monthly payroll or the weekly payroll, and are members of the sports club if they so wish. Description 2: PC Associates is a large, multinational consulting corporation, which uses a number of PCs and software packages in the course of her work. PC Associates needs to maintain the following information about the PCs and software packages its employee uses to do their jobs. For each PC, the computer number, the computer model and manufacturer, and the type of microprocessor needed to be stored. Data for each employee also needed to be stored - such as the employee name, employee number, and phone number. Also for each PC, the inventory tag number, location, computer number and the number of the employee who owns the PC. For each software package, the package number, current cost, type, name and version needed to be stored. Also for each software package installed on a PC, the package number and cost, installation date and inventory tag number needed to be stored. Analyze and create the database structure for PC Associates

6 & 7 PL/SQL Programs using control structures

a) Write a PL/SQL code block that will accept an account number from the user, check if the users balance is less than minimum balance, only then deduct Rs 100/- from the balance. The process is fired on the ACCT_MSTR table.

b) Write a PL/SQL code block to calculate the area of a circle for a value of radius varying from 3 to 7. Store the radius and the corresponding values of calculated area in an empty table named Areas, consisting of two columns Radius and Area.

c) Write a PL/SQL block of code to achieve the following: If there are no transactions taken place in the last 365 days then mark the account status as inactive, and then record the account number, the opening date and the type of account in the IN_ACCT_MSTR table.

d) The bank manager has decided to transfer employees across branches. Write a PL/SQL block to accept an employee number and the branch number followed by updating the branch number of that employee to which he belongs appropriately. Display an appropriate message using SQL%FOUND based on the existence of the record in the EMP_MSTR table. Display an appropriate message using SQL%NOTFOUND based on the non-existence of the record in the EMP_MSTR table.

e) The bank manager of jublee hills branch decides to activate all those accounts, which were previously marked as inactive for performing no transactions in last 365 days. Write a PL/SQL block to update the status of accounts. Display an appropriate message based on the number of rows affected by the update fired.

f) The bank manager has decided to mark all those accounts as inactive(I) on which there are no transactions performed in the last 365 days. Whenever any such update takes place, a record for the same is maintained in the INACTV_ACCT_MSTR table comprising of the account number, the opening date and the type of account. Write a PL/SQL block to do the same.

Page 7: COMPUTER SCIENCE AND ENGINEERING - Yolavardhamancse.yolasite.com/resources/4th DBMS LAB MANUAL.pdf · 1 (Autonomous) Shamshabad-501218, Hyderabad COMPUTER SCIENCE AND ENGINEERING

7

g) Write a PL/SQL block of code such that depending upon a user supplied account number, the customer to whom the account belongs, the introducer of that account and the nominee of that account are inserted into the ACCT_MSTR table, then the PL/SQL block must display appropriate error message back to the user.

h) Two client machines (P and Q) are accessing the same ACCT_MSTR table using identical PL/SQL code blocks for updating the CURBAL column of the table ACCT_MSTR.

i) The PL/SQL program to find the sum of each digit of given number? j) Write the PL/SQL program for the sum of square of the given

number? k) Write a PL/SQL program to accept 2 parameters, 1st parameter will

be the string and the 2nd parameter should specify which part of the string. 1 means 1st half and 2 means the 2nd half. (Example: hello, 1 should return ‘hel’ and hello, 2 should return ‘lo’).

l) Write a PL/SQL program to accept a string and remove the vowels from the string.( When ‘hello’ passed to the program it should display ‘Hll’ removing e and o from the world Hello).

m) Write a PL/SQL program to accept a number and a divisor. Make sure the divisor is less than or equal to 10. Else display an error message. Otherwise Display the remainder in words.

Functions a) Write a function to accept employee number as parameter and return basic+hra together as single column.

b) Accept year as parameter and write a Function to return the total net salary spent for a given year.

c) Create a function to find the factorial of a given number and hence find NCR?

d) Write a PL/SQL block o pint prime Fibonacci series using local functions.

e) Create a procedure to find the lucky number of a given birth date? f) create function to the reverse of given number

8 Cursors a) Write a PL/SQL block that will display the name, dept no, salary of fist highest paid employees.

b) Update the balance –stock in the item master table each time a transaction takes place in the item transaction table. The change in item master table depends on the item id is already present in the item master then update operation is performed to decrease the balance stock by the quantity specified in the item transaction in case the item id is not present in the item master table then the record is inserted in the item master table

c) Write PL/SQL program to print highest paid employee details using cursors

d) Write PL/SQL program to print Employee details along with salary using cursors

e) Write PL/SQL program to delete rows from table using cursors

Triggers a) Convert employee name into uppercase whenever an employee record is inserted or updated. Trigger to fire before the insert or update?

b) Trigger before deleting a record from emp table. Trigger will insert the row to be deleted into table called delete _emp and also record

Page 8: COMPUTER SCIENCE AND ENGINEERING - Yolavardhamancse.yolasite.com/resources/4th DBMS LAB MANUAL.pdf · 1 (Autonomous) Shamshabad-501218, Hyderabad COMPUTER SCIENCE AND ENGINEERING

8

user who has deleted the record and date and time of delete? c) PL/SQL program to update a row from employee table using Triggers d) PL/SQL program for deletion of row from employee table using

Triggers. e) Create a transparent audit system for a table CUST_MSTR. The

system must keep track of the records that are being deleted or updated.

9 Case study: Book Publishing Company

A publishing company produces scientific books on various subjects. The books are written by authors who specialize in one particular subject. The company employs editors who, not necessarily being specialists in a particular area, each take sole responsibility for editing one or more publications. A publication covers essentially one of the specialist subjects and is normally written by a single author. When writing a particular book, each author works with on editor, but may submit another work for publication to be supervised by other editors. To improve their competitiveness, the company tries to employ a variety of authors, more than one author being a specialist in a particular subject

For the above Case study, do the following. 1. Analyze the data required. 2. Normalize the attributes. 3. Create the logical data model (ER diagrams).

10 Case study: General Hospital

A General Hospital consists of a number of specialized wards (such as Maternity, Pediatric, Oncology, etc). Each ward hosts a number of patients, who were admitted on the recommendation of their own GP and confirmed by a consultant employed by the Hospital. On admission, the personal details of every patient are recorded. A separate register is to be held to store the information of the tests undertaken and the results of a prescribed treatment. A number of tests may be conducted for each patient. Each patient is assigned to one leading consultant but may be examined by another doctor, if required. Doctors are specialists in some branch of medicine and may be leading consultants for a number of patients, not necessarily from the same ward.

For the above Case study, do the following. 1. Analyze the data required. 2. Normalize the attributes. 3. Create the logical data model (ER diagrams).

11 Case study: Car Rental Company

A database is to be designed for a Car Rental Company (CRC). The information required includes a description of cars, subcontractors (i.e. garages), company expenditures, company revenues and customers. Cars are to be described by such data as: make, model, year of production, engine size, fuel type, number of passengers, registration number, purchase price, purchase date, rent price and insurance details. It is the company policy not to keep any car for a period exceeding one year. All major repairs and maintenance are done by subcontractors (i.e. franchised garages), with whom CRC has long-term agreements. Therefore the data about garages to be kept in the database includes garage names, addresses, range of services and the like. Some garages require payments immediately after a repair has been made; with others CRC has made arrangements for credit facilities. Company expenditures are to be registered for all outgoings connected with purchases, repairs, maintenance, insurance etc. Similarly the cash inflow coming from all sources - car hire, car sales, insurance claims - must be kept of file.CRC maintains a reasonably stable

Page 9: COMPUTER SCIENCE AND ENGINEERING - Yolavardhamancse.yolasite.com/resources/4th DBMS LAB MANUAL.pdf · 1 (Autonomous) Shamshabad-501218, Hyderabad COMPUTER SCIENCE AND ENGINEERING

9

client base. For this privileged category of customers special credit card facilities are provided. These customers may also book in advance a particular car. These reservations can be made for any period of time up to one month. Casual customers must pay a deposit for an estimated time of rental, unless they wish to pay by credit card. All major credit cards are accepted. Personal details (such as name, address, telephone number, driving license, number) about each customer are kept in the database.

For the above Case study, do the following.

1. Analyze the data required. 2. Normalize the attributes. 3. Create the logical data model (ER diagrams).

12 Case study: Student Progress Monitoring System

A database is to be designed for a college to monitor students' progress throughout their course of study. The students are reading for a degree (such as BA, BA(Hons) MSc, etc) within the framework of the modular system. The college provides a number of modules, each being characterized by its code, title, credit value, module leader, teaching staff and the department they come from. A module is co-ordinated by a module leader who shares teaching duties with one or more lecturers. A lecturer may teach (and be a module leader for) more than one module. Students are free to choose any module they wish but the following rules must be observed: some modules require pre-requisites modules and some degree programmes have compulsory modules. The database is also to contain some information about students including their numbers, names, addresses, degrees they read for, and their past performance (i.e. modules taken and examination results). For the above Case study, do the following. 1. Analyze the data required. 2. Normalize the attributes. 3. Create the logical data model (ER diagrams). 4. Comprehend the data given in the case study by creating respective tables with

primary keys and foreign keys wherever required.

5. Insert values into the tables created (Be vigilant about Master- Slave tables).

6. Display the Students who have taken M.Sc course.

7. Display the Module code and Number of Modules taught by each Lecturer.

8. Retrieve the Lecturer names who are not Module Leaders.

9. Display the Department name which offers ‘English’ module.

10. Retrieve the Prerequisite Courses offered by every Department (with Department

names).

11. Present the Lecturer ID and Name who teaches ‘Mathematics’.

12. Discover the number of years a Module is taught.

13. List out all the Faculties who work for ‘Statistics’ Department.

14. List out the number of Modules taught by each Module Leader.

15. List out the number of Modules taught by a particular Lecturer.

16. Create a view which contains the fields of both Department and Module tables. (Hint-

The fields like Module code, title, credit, Department code and its name).

17. Update the credits of all the Prerequisite courses to 5.

18. Delete the Module ‘History’ from the Module table (Be vigilant about foreign key

references).

Page 10: COMPUTER SCIENCE AND ENGINEERING - Yolavardhamancse.yolasite.com/resources/4th DBMS LAB MANUAL.pdf · 1 (Autonomous) Shamshabad-501218, Hyderabad COMPUTER SCIENCE AND ENGINEERING

10

13

Case Study: Computer Sales Administration System A relational database is to be designed for a medium sized Company dealing with industrial applications of computers. The Company delivers various products to its customers ranging from a single application program through to complete installation of hardware with customized software. The Company employs various experts, consultants and supporting staff. All personnel are employed on long-term basis, i.e. there are no short-term or temporary staff. Although the Company is somehow structured for administrative purposes (that is, it is divided into departments headed by department managers) all projects are carried out in an inter-disciplinary way. For each project a project team is selected, grouping employees from different departments, and a Project Manager (also an employee of the Company) is appointed who is entirely and exclusively responsible for the control of the project, quite independently of the Company's hierarchy. The following is a brief statement of some facts and policies adopted by the Company.

• Each employee works in some department. • An employee may possess a number of skills • Every manager (including the MD) is an employee • A department may participate in none/one/many projects. • At least one department participates in a project. • An employee may be engaged in none/one/many projects

For the above Case study, do the following. 1. Analyze the data required. 2. Normalize the attributes. 3. Create the logical data model (ER diagrams). 4. Comprehend the data given in the case study by creating respective tables with

primary keys and foreign keys wherever required. 5. Insert values into the tables created (Be vigilant about Master- Slave tables). 6. Retrieve the Projects developed by a particular Department. 7. List out the projects which exceeds deadline with respect to sysdate. 8. Retrieve the Department(s) which have not involved in any of the Projects

developed by the Organization. 9. List out the Team Members of a particular Manager. 10. List out the Managers involved in a particular (multidisciplinary) project. 11. List out the Projects developed by each Department. 12. Retrieve the multidisciplinary project which involves more than 2 Departments. 13. Display the Project details with Employees who have involved in its development. 14. Display the employee details according to Department. (Group By) 15. Display the project which ranks the second maximum budget. 16. Create a view which contains the Manager and his Team Member details. 17. Display the months between the starting date and ending date of each project. 18. Delete the Department which didn’t involve in any of the Project development.

14 Case Study: Department Vendor Database System You are a systems analyst. You have been assigned to design a database management system (DBMS) for Mechanical Engineering (ME), Inc. ME orders its parts from two types of vendors--local and nonlocal vendors. Vendors are tracked by vendor #, n ame, address, and telephone #. Parts are ordered by means of a purchase order. Local vendors can supply both assembled and sub-parts, while nonlocal vendors can supply only subparts. For each order, ME would like keep track of information such as order #, quantity ordered, date requested and date shipped. A single part is ordered on each purchase order. A part can be an assembled part or a sub-part. An assembled part can contain two or more sub-parts and each sub-part can be used in two or more assembled parts. Parts should have: part #,

Page 11: COMPUTER SCIENCE AND ENGINEERING - Yolavardhamancse.yolasite.com/resources/4th DBMS LAB MANUAL.pdf · 1 (Autonomous) Shamshabad-501218, Hyderabad COMPUTER SCIENCE AND ENGINEERING

11

description, and cost. ME has requested that the DBMS that you design should provide capability to list the sub-parts that make up an assembled part and from which vendor it is ordered. For the given case study, do the following thing:

1. Draw an entity-relationship diagram and translate it into relational tables, for example: student (student id, name, address, major, dept.), etc.

2. Comprehend the data given in the case study by creating respective tables with primary keys and foreign keys wherever required.

3. Insert values into the tables created (Be vigilant about Master- Slave tables). 4. List the Subparts of an Assembled part with the Vendor details. 5. List the parts which are ordered between 01-Jan-2011 and 01-Jan-2012 with vendor

details. 6. List the Vendors who have delivered products within 6 months from order date. 7. Display the details of the Assembled parts in which a given Sub part is implanted. 8. Display the Vendor details who have supplied both Assembled and Sub parts. 9. Display the Sub parts by grouping the Vendor type (Local or Non Local). 10. Display the Sub part which costs more than any of the Assembled parts. 11. Display the second maximum cost Assembled part. 12. Display the Vendor details in ascending order. 13. Display the Assembled part with its Sub parts by ordering the Assembled part id in

descending order. 14. Create a view that contains Assembled parts and its corresponding Sub parts. 15. Update the phone number of a Vendor. 16. Delete the Vendor who have not supplied the parts within 12 months from order date.

FACULTY INCHARGE HOD, CSE