You are on page 1of 3

DBMS - Exercise 1 Consider the following entities & their relationships: Subject (sb_no, sb_name, sb_score) Student (st_no,

st_name, st_class, st_age) Subject and Student are related with many to many relationships. Create a relationship database for above. Use the above data for solving following queries. a. Write a trigger, which will get activated when subject Statistics is updated. It should update the marks entered in the range of 28 to 31 to passing marks 32. b. Write a stored procedure, which will take subject name as parameter & will find out names of students those who had attempted the subject. Create a database in the SQL Server with a table named student having fieldsstudent name, class and percentage. Fill in the data. Write a program that would use the SQL Server.NET data provider to retrieve and display the list of students that have percentages above 60%. Consider following entities & their relationships. Item (ItemNo, ItemName, Quantity) Supplier (SuppNo, SuppName, SuppAddr, City, PhNo) Item & Supplier are related with many to many relationships with rate and discount as attribute of relationship Solve the following queries for the above data. a. Define a trigger before updation on discount field. If difference in old discount & new discount is >4% then raise as exception & display corresponding message. Write a code to list suppliers who live in some other city but supply only one item. Create a database in the SQL Server with a table named Employee having fields-Employee name, Department and Salary. Fill in the data. Write a program that would use the SQL Server.NET data provider to retrieve and display the list of employees that have salary above 15000.00. Consider the following entities & their relationships: Student (st_no, st_name, st_class, st_age) Subject (sb_no, sb_name, sb_score) Student and Subject are related with many to many relationships. Create a relationship database for above. Use the above data for solving following queries. c. Write a trigger, which will get activated when subject Fundamental is updated. It should update the marks entered in the range of 28 to 31 to passing marks 32. d. Write a stored procedure, which will take subject name as parameter & will find out names of students those who had attempted the subject. CREATE TABLE EMP having fields Field name Datatye Width EMPNO NUMERIC 4 NOT NULL ENAME CHAR 12 NOT NULL

DBMS - Exercise JOB CHAR 10 JOIN_DT DATETIME NOT NULL DEPTNO NUMERIC 4 NOT NULL i) Write a query to display Job, group by job and count job greater than 1 ii) Write a query to display ename, empno, join_dt from emp where job is manager and join_dt is greater than 01-Jan-97. Consider following entities & their relationships. Item (ItemNo, ItemName, Quantity) Supplier (SuppNo, SuppName, SuppAddr, City, PhNo) Item & Supplier are related with many to many relationships with rate and discount as attribute of relationship Solve the following queries for the above data. b. Define a trigger before updation on discount field. If difference in old discount & new discount is >4% then raise as exception & display corresponding message. Write a code to list suppliers who live in some other city but supply only one item. Create a database in the SQL Server with a table named Worker having fields-Worker name, Department and Salary. Fill in the data. Write a program that would use the SQL Server.NET data provider to retrieve and display the list of workers that have salary above 20000.00. Consider the following entities & their relationships: Employee(EMPNO, DEPTNO, SALARY,DA) Department (DEPTNO, DEPT_NAME, DESCRIPTION) Employee and Department are related with many to many relationships with attribute DEPTNO. Create a relationship database for above. Build the queries for the above data. e. Display the records of employees whose department name is Production. f. Display the records of employees whose salary is above 15000. and whose department is Supplier. Create a database in the SQL with a table named student having fields-student name, class and percentage. Fill the data in it. Write a query that retrieve and display the list of students that have percentages above 60%. Consider following entities & their relationships. Product (Product_ID, Product_name, category_id, unitprice, reorderlevel, Unit_In_Stock) Category(category_id, category_name, Desription) Product & Category are related with one to many relationships with category_id as attribute of relationship Define the following queries for the above data. c. Display the records from Product Table whose category_id is C01.

10

11

12

13

14

15

16

17

DBMS - Exercise d. Display the records from Product Table whose Unit_Price is greater than 20000. Create a database in the SQL Server with a table named Employee having fields-Employee name, Department and Salary. Fill the data in it. Write a Query that retrieve and display the list of employees that have salary above 15000.00. Consider the following entities & their relationships: Acctmast (Acctno, Name, Period) Accttran (Acctno, TrnDate, Amount, Processed) Acctmast and Accttran are related with One to many relationships. Create a relationship for above database. Define the following queries for the above data. 1. Display the records from Accttran Table whose Account name is Saving. 2. Display the records from Accttran whose Balance is greater than 50000. CREATE TABLE EMP having fields Field name Datatye Width EMPNO NUMERIC 4 NOT NULL ENAME CHAR 12 NOT NULL JOB CHAR 10 JOIN_DT DATETIME NOT NULL DEPTNO NUMERIC 4 NOT NULL i) Write a query to display Job, group by job and count job greater than 1 ii) Write a query to display ename, empno, join_dt from emp where job is manager and join_dt is greater than 01-Jan-97.

18

19

20

21

You might also like