Database management system lab
Course code: DSC4 Lab
Program list
SQL 1: Create Following tables and insert tuples with suitable constraints
Table: Item
ICode IName Price Color VCode
S001 Mobile phones 30000 Silver P01
S002 Refrigerator 20000 Cherry P02
S003 Tv 45000 Black P03
S004 Washing 12000 White P04
machine
S005 Air conditioner 50000 White P05
Table: Vendor
VCode VName
P01 Rahul
P02 Mukesh
P03 Rohan
P04 Kapil
P05 Rajesh
1. Create Tables using create statement
2. Insert rows to individual tables using insert statement
3. update the price of the Air Conditioner (S005) to 55000?
4. count the total number of items in the Item table?
5. delete the Refrigerator (S002) from the Item table?
SQL 2: Create Following tables and insert tuples with suitable constraints
Table Name: Employee
EMPLOYEE_ID FIRST_NAME LAST_NAME SALARY JOINING_DATE DEPARTMENT
1 John Abraham 1000000 01-JAN-13 Banking
2 Michael Clarke 800000 01-JAN-13 Insurance
3 Roy Thomas 700000 01-FEB-13 Banking
4 Tom Jose 600000 01-FEB-13 Insurance
5 Jerry Pinto 650000 01-FEB-13 Insurance
6 Philip Mathew 750000 01-JAN-13 Services
7 raj Kapoor 650000 01-JAN-13 Services
8 Ravi kumar 600000 01-FEB-13 Insurance
Table Name: Incentives
EMPLOYEE_REF_ID INCENTIVE_DATE INCENTIVE_AMOUNT
1 01-FEB-13 5000
2 01-FEB-13 3000
3 01-FEB-13 4000
1 01-JAN-13 4500
2 01-JAN-13 3500
Write queries for the following:
1. Get all employee details from the employee table
2. Get all employee details from the employee table order by First_Name
descending
3. Get employee details from employee table whose employee name is “John”
4. Get employee details from employee table whose first name ends with 'n'
5. Get employee details from employee table whose Salary greater than 600000
6. Get employee details from employee table whose joining year is “2013”
7. Get difference between JOINING_DATE and INCENTIVE_DATE from
employee and incentives table.
SQL 3: Create Following tables and insert tuples with suitable constraints
Table: Books
Table: Issued
Write queries for the following:
1. Retrieve all books that are Fiction type
2. Find books that have a price greater than 500
3. Find books that have been issued
4. Display Book list other than, type Novel and Fiction
5. Select Book_Id, Book_Name, Author Name, Quantity Issued where Books.Books_Id
= Issued.Book_Id
6. Display Book id, Book name and publisher of books having quantity more than 8 and
price less than 500
7. Display book details with author name starts with letter “T” and ends with “S”
SQL 4: Create Following tables and insert tuples with suitable constraints
Write queries for the following
1. Select all students from physics and Computer Science
2. Display all student details those are studying in second year
3. select all student having PMCs combination
4. Rename table Computer Science to CS
5. Drop column year from computer science table
SQL 5 : Create Following tables and insert tuples with suitable constraints
Write queries for the following:
1. To display Name and Price of all the Accessories in descending order of their Price
2. (ii) To display Id and Sname of all the Shoppe location in 'Nehru Place'
3. (iii) To display Name, Minimum and Maximum Price of each Name from
ACCESSORIES table
4. (iv) To display Name, Price of all Accessories and their respective SName from table
SHOPPE and ACCESSORIES where Price is 5000 or more.
5. (v) To display all details of accessories where name contains word 'Board';
SQL 6 : Create Following tables and insert tuples with suitable constraints
Write queries for the following:
1. Display Total Number of accounts present in each branch
2. Display Total Loan amount in each branch
3. Display Total deposited amount in each branch by descending order
4. Display max , min loan amount present in each city.
5. Display average amount deposited in each branch, each city
6. Display maximum of loan amount in each branch where balance is more than 25000
7. Display Total Number of accounts present in each city
8. Display all customer details in ascending order of brach_id
9. Update Balance to 26000 where accno=AE1003996
10. Display Customer Names with their branch Name
SQL 7: Create Following tables and insert tuples with suitable constraints
Write queries for the following:
1. To display PatNo, PatName and corresponding DocName for each patient.
2. To display the list of all doctors whose NoofOpdDays are more than 3
3. To display DocName, Department, PatName and DocId from both the tables where
DocID is either 101 or 103
4. To display total no of different departments from patient’s table.
5. Show the structure of the table patients
SQL 8: Create Following tables and insert tuples with suitable constraints
Consider the product table with the following attributes
Product_no, product_name, product_type, MRP, YEAR_Of_manfacutred, company, phone_no
Write queries for the following:
1. Create appropriate table
2. Insert 10 tuples
3. Display the details of product table
4. Display the product details whose name starts with ‘A’
5. Update the table by adding values for the new column ‘no of employees’
6. Display the product whose MRP is more than 2000 and the product type is electronics
7. Display the product whose year_of_manfacutring is 2015 and it is manufacture in mysore
8. Drop a column for product table
9. Find the average MRP for each company
10. Find the total MRP of all products grouped by product type