You are on page 1of 2

Programme : B.

Tech CSE Semester : Win 2016-17


Database Management Systems
Course : Code : CSE2004
(Embedded Lab)
Faculty : Dr. B. Saleena Slot : L31 + L32

Ex. No: 3 Date: 30/01/2017

SQL - DML Commands & Aggregate Functions

Create the following tables and apply constraints as follows


1. Books Table:
a. isbn primary key
b. Title Not Null
c. price Not null
d. qty Not null
2. Authors Table:
a. authorId primary key
b. email unique Key

3. Book_Authors:
a. isbn foreign key references books table
b. authorId foreign key references authors table
Additional Exercises on DML Commands

1. Increase the price of all the books by Rs. 5


2. List the author names without repetition from book_authors
3. List the author details whose name as well as email starts with t
4. Copy the author table contents and name the table as author_new
5. Rename the name attribute as author_name
6. Delete all author details from author_new table, whose author_name has i as a character
7. Display the author_new table after deletion
8. Delete all tuples from author_new
9. Display the author_new table after deletion
10. Delete the structure of author_new table and check the existence of the structure after
deletion.

Queries based on Aggregate Functions

1. Find the number of tuples from books


2. List the distinct authors from books_authors
3. Find the total number of quantities of books available in books relation
4. Find the average price of the books in books relation
5. List the author_id with the number of books written by each author from book_authors
6. Find the author_id who have wtitten more than 2 books from book_authors
7. Display the first 5 characters of all email ids from authors
8. List the author_id and the number of characters present in their email ids from authors
9. Display the price of the books with no decimal points from books relation
10. Consider a date (dd/mmm/yyyy) and display the month after 3 months from the given
date.

You might also like