Sie sind auf Seite 1von 6

Data Base Management System Lab MCA-156

Number of Credits allotted=1 Number of lab session (2 hrs each) = 14 approx. (One Lab session per week)

The inputs from various Institutes as submitted to the coordination committee have been taken into account for preparation of the Final List given below:

Write the queries to create following tables Table 1: Dept_master Field Name Dept_no Department_Name Department_Location Data type Varchar2 Varchar2 Varchar2 Size 5 25 30 Constraint Primary key/Start with d

Table 2: Employee_master Field Name Data Type Employee_no Varchar2 Employee_name Varchar2 Address1 Varchar2 Address2 Varchar2 DateofBirth Date Basic Number Commission Number Dept_no Varchar2 Designation Varchar2

Size 6 30 30 30 6,2 6,2 5 6

Constraint Start with e

Depentdent on dept_no of dept_master Default mstaff values if any can be any of cman, vp, mgr, slman and mstaff

Table 3: Vendor_master Field Name Vendor_id Vendor_name Address1 Address2 City State Pincode Phone Data type Varchar2 Varchar2 Varchar2 Varchar2 Varchar2 Varchar2 Number number Size 6 25 25 25 20 15 6 10 Constraint Primary key/ start with v

Table 4: Material_master

Field Name Material_id Material_desc Unit_price Unit_measure Stock Table 4: Order_master Field Name Vendor_id Material_id Quantity_ordered Date_ordered Order_id Sell_price Employee_no Delivery_status Qty_delivered

Data type Varchar2 Varchar2 Number Varchar2 number

Size 6 25 6,2 6 3

Constraint Primary key/ start with m

Data type Varchar2 Varchar2 number Date Varchar2 number Varchar2 Char number

Size 6 6 4 6 6,2 6 1 4

Constraint Dependent on vendor_id of vendor_master Dependent on material_id of material_master Greater than zero Default system date Primary key start with o Greater than zero Default p can have value f or p Less than quantity_ordered and greater than zero

Unit II

Topics Identified Use of Primary Key & foreign key Through Alter

Suggested Problems Modify the structure of the employee_master table to have primary key constraint on the filed employee_no.

Q. Modify the structure of order_master table to have foreign key constraint on the field employee_no.

Use of BETWEEN, IN, LIKE,NOT IN through where clause in select

Q. Write a query to select the vendor id, name and phone o. of vendor who lives in the state of u.p.

Q. Write a query to select the name and address of vendor whose name contain the letter a.

Q. Write a query to count the no. of vendors who fall in the state of uttar pradesh If the no. of vendors in the state of uttar pradesh are 3, the result should be as :

RESULT ------------No. of vendors in the state of uttar pradesh is 5

Q. Write a query to select the vendor id, name and state of the vendor whose assress2 field has a . Contained in it.

Q. Write a query to list the details of vendors who does not belong to the state of uttar Pradesh and rajasthan Q. Write a query to list the material id, its description and stock available for those whose unit price falls above 600 but less than 900.

Q. Write a query to display the information of a material whose unit price is either 450.25 or 500 or 700 or 900.

Q. Write a query to display the information about the material value in the stock is less than 5.

Use of Update Command

Q. Write a query to change the address1 of vendor to 186, circular no. 2 whose vendor id is v1001.

Q. Modify the date of birth to 23-aug-67 where employee id is e10126.

Q. Write a query to inform you about the vendor(s) in the following form :- (e.g.) INFORMATION ----------------------

Vendor with id as v1001 lives in the state of uttar Pradesh.

Use of And operator in Select :

Q. Write a query to display the names of all employees whose commission is more than 10% of their basic salary and falls in the category of salesman.

Use of Sub Query:

Q. Write a query to select the employee no. and name of those employees who earn salary more than the average salary of all the employees working in the organization.

Use of function MAX ,MIN,AVG:

Q. Write a query to select the minimum, maximum and average salary of the employees working in the organization. The headings should be smi, smx and sav respectively.

Use of Group by and Order By

Q. Write a query to display the employee id, name and department no. of all employees who are either working as salesman or miscellaneous staff. The grouping should be department wise. Within the department, it should have all salesman together and all miscellaneous staff together.

Q. Write a query to inform you about the no. of employees working for each department.

Q. Write a query to select the name, department name and location of employee who are designated as manager.

Use of Joins:

Q. Write a query to display the name, designation, department name and location who does not work in the Kanpur office.

Q. Write a query to list the name and id of all employees in alphabetical order of their name.

Q. Write a query to select the name and date of birth of those

employees who are born before February 7, 1976.

Q. Write a query to select the name and department of those employees who have age between 30 and 40 years.

Q. Write a query to select the name and basic salary of employees who have a letter e ors in their names. Further, modify the query list for those who does not contain m in their names.

Q. Write a query to list the id, name and department no. of employees who are born in the month of February. III Use of Joins & Triggers: Create the table and list the employee detail along with the contact detail using left Outer join Create a repot using cross join that will display the maturity amount for predefined deposits based on the max and min periods fixed / time deposits. Create the table and list the employee detail along with the contact detail using right Outer join Create a transparent audit system for a table cust_master the system must keep track of the records that are being deleted or updated. The functionality being when a record is deleted or modified the original record details and date of operation are stored in the audit table, then the delete or update operation is allowed to go through.

Use of Procedures and Functions:

Write a PL/SQL code that accept the account number from the user and check the users balance is less than minimum balance , only then deduct Rs. 200/- from the balance . The process is fired on the Acct_Mstr table. Create a simple loop such that a message is displayed when a loop exceeds a particular value.

Write a PL/SQL code 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.

Write a PL/SQL code that first withdraws an amount of Rs. 1500/-. Then deposits an amount of Rs. 50,000.Update the current balance . Then check to see that the current balance of all the accounts in the bank does not exceed Rs. 60,000. If the balance exceeds Rs 60,000 then undo the deposit just made.

Write a PL/SQL code that will reverse a given number like 12345 to 54321

Use of Error Handling

Write a PL/SQL code that will check the error produced by query and display an appropriate message.

Use of Cursors :

Write a PL/SQL code that accepts 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 a message using SQL %NOTFOUND based on the no existence of the record in the emp_ mst table.

The bank manager of delhi branch decide to activate all those accounts,which were previously marked as in active for performing no transaction in last 365 days. Write a PL/SQL code to update the status of account. Display an appropriate message based on the no of rows affected by the update fired.

The proposed list is the minimal that should be implemented for the course.

However, more practical can be introduced at Institute level depending on students performance in the Lab and their grasping power, as discussed in the Meeting on 20th Dec 2010.

Das könnte Ihnen auch gefallen