DBMS Lab Assignment Questions

These are DBMS Lab Assignment Questions for practice RDBMS in a lab environment and all queries were tested using Oracle 10g. The Queries may not give you expected result if you implement them on any other DBMS setup without necessary modifications.

Advertisements

Q1: Consider the following relational schema for the Office of the Controller of Examinations Application.

Student (Rollno, Name, Dob, Gender, Doa, Bcode);

Implement a check constraint for

  • Gender
  • Date of Admission

Branch (Bcode, Bname, Dno);

Department (Dno, Dname);

Course (Ccode, Cname, Credits, Dno);

Branch_Course (Bcode, Ccode, Semester);

Enrolls (Rollno, Ccode, Sess, Grade);

For Example,

SESS can take values ‘APRIL 2013’, ‘NOV 2013’

Implement a check constraint for grade Value Set (‘S’, ‘A’, ‘B’, ‘C’, ‘D’, ‘E’, ‘U’ );

Students are admitted to Branches and they are offered by Departments. A branch is offered by only one department.

Each branch has a set of Courses (Subjects). Each student must enroll during a semester. Courses are offered by Departments. A course is offered only by one department. If a student is unsuccessful in a course he/she must enroll for the course during next session. A student has successfully completed a course if the grade obtained by is from the list (A, B, C, D, and E).

A student is unsuccessful if he/she have grade ‘U’ in a course.

Primary Keys are underlined.

Questions

These are questions for assignment 1. The solution is available after the last question.

Question (A)

Develop a SQL query to list details of Departments that offer more than 3 branches.

Question (B)

Develop a SQL query to list the details of Departments that offer more than 6 courses.

Question (C)

Develop a SQL query to list the details of courses that are common for more than 3 branches.

Question (D)

Develop a SQL query to list students who got ‘S’ in more than 2 courses during single enrollment.

Question (E)

Create a view that will keep track of the roll number, name and number of courses, a student has completed successfully.

Q2: Consider the following relations for an Order Processing Database application in a Company.

Customer (Customerno varchar2 (5), Cname varchar2 (50));

Implement check constraints to check Customerno starts with ‘C’.

Cust_Order (Orderno varchar2(5), Odate Date, Customerno references Customer, Ord_amt number(8));

Implement check constraints to check Orderno starts with ‘O’.

Ord_amt is derived attribute (default value is 0);

Item (Itemno varchar2 (5), Item_name varchar2 (30), unit_price number (5));

Implement check constraint to check Itemno starts with ‘I’.

Order_item (Orderno references Cust_order, Itemno references item, qty number (3));

Primary Key is underlined.

Questions

These are questions for assignment 2. The solution is available after the last question.

Question (A)

Develop DDL to implement above schema enforcing primary key, check constraints and foreign key constraints.

Question (B)

Populate Database with rich data set.

Question (C)

Develop SQL query to list the details of customers who have placed more than 3 orders.

Question (D)

Develop a SQL query to list details of items whose price is less than the average price of all items in each order.

Question (E)

Develop a SQL query to list the orderno and number of items in each order.

Question (F)

Develop a SQL query to list the details of items that are present in 25% of the orders.

Question (G)

Develop an update statement to update the value of Ord_amt.

Question (H)

Create a view that keeps track of detail of each customer and number of Order placed.

Advertisements

Q3: Consider the following relational schema

Staff (Staffno number (5), Name varchar2 (30), Dob Date, Gender Char (2), Doj Date, Designation varchar2 (30), Basic_pay number (6), Deptno varchar2 (5));

Gender must take value ‘M’ or ‘F’.

Dept (Deptno varchar2 (5), Name varchar2 (30));

Skill (Skill_code varchar2 (5), Description varchar2 (30), Charge_Outrage number (3));

Staff_skill (Staffno number (5), Skill_code varchar2 (5));

Project (Projectno varchar2 (5), Pname varchar2 (5), Start_Date Date, End_Date Date, Project_Manager_Staffno number (5));

Project Number must start with ‘P’.

Works (Staffno number (5), Projectno varchar2 (5), Date_Worked_On Date, Intime Timestamp, Outtime Timestamp);

Primary Key is underlined.

Questions

These are questions for assignment 3. The solution is available after the last question.

Question (A)

Develop DDL to implement the above schema specifying appropriate data types for each attributes and enforcing primary key, check constraints and foreign key constraints.

Question (B)

Populate the database with rich data set.

Question (C)

Develop a SQL query to list the departmentno and number of staff in each department,

Question (D)

Develop a SQL query to list the details of staff who earn the AVG basic pay of all staff.

Question (E)

Develop a SQL query to list the details of staff who have more than 3 skills.

Question (F)

Develop a SQL query to list the details of staff who have skills with a charge outrate greater than 60 per hour.

Question (G)

Create a view that will keep track of the department number, department name, the number of employees in the department and total basic pay expenditure for the department.

Question (H)

Develop a SQL query to list the details of Depts which has more than 5 staff working in it.

Question (I)

Develop a SQL query to list the details of staff who have more than 3 skills.

Q4: Consider the following relational schema for a banking database application.

Customer (Cid, Cname);

Branch (Bcode, Bname);

Account (Ano, Atype, Balance, Cid, Bcode);

An account can be a saving account or a current account. Check Atype in ‘S’ or ‘C’. A customer can have both types of accounts.

Transaction (Tid, Ano, Tttype, Tdate, Tamount);

Ttype can be ‘D’ or ‘W’.

D – Deposit, W – Withdrawal

Primary Key is underlined.

Questions

These are questions for assignment 4. The solution is available after the last question.

Question (A)

Develop DDL to implement the above schema specifying an appropriate data type for each attribute enforcing primary key, check constraints and foreign key constraints.

Question (B)

Populate the database with a rich data set.

Question (C)

Develop a SQL query to list the details of customers who have a saving account and a current account.

Question (D)

Develop a SQL query to list the details of branches and the number of accounts in each branch.

Question (E)

Develop a SQL query to list the details of branches where the number of accounts is less than the average number of accounts in all branches.

Question (F)

Develop a SQL query to list the details of customers who have performed three transaction on a day.

Question (G)

Create a view that will keep track of branch details and the number of accounts in each branch.

Advertisements

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Exit mobile version