You are on page 1of 2

SQL

1. List and briefly explain various data types that are allowed for SQL attributes.
2. Explain the following with their syntax and example.
i. CREATE TABLE command
ii. SELECT statement
iii. UPDATE command
iv. DROP command
3. How does SQL allow implementation of the entity integrity and referential
integrity constraints?
4. Explain the ALTER TABLE command. Explain how a new constraint can be
added and also an existing constraint can be removed using suitable
examples.
5. How do the relations (tables) in SQL differ from the relations defined
formally? Discuss the differences in terminology. Why does SQL allow
duplicate tuples in a table or in a query result?
6. Write short notes on Embedded SQL and transaction support in SQL.
7. Explain IN and EXISTS operator with suitable examples.
8. Explain the following with respect to SQL giving examples.
i) Views ii) Aggregate functions
9. Explain how GROUP BY clause works. What is difference between WHERE and
HAVING clause?
10.Explain insert, delete, and update statements in SQL with examples.
11.How is a view created and dropped? What problems are associated with
updating of views?
12.For the database schema, given below.

Specify the following queries in SQL.

i. Retrieve the names of all senior students majoring in 'cs' (computer


science).
ii. Retrieve the names of all courses taught by Professor King in 1998 and
1999.
iii. For each section taught by Professor King, retrieve the course number,
semester, year, and number of students who took the section.

13.Consider the following schema for a company database.


Employee (Name, SSN, Salary, Dno, SuperSSN)
Department (DName, DNos, MGRSSN)
Project (Pname, Pnumber, DNum)
Works ON (ESSN, PNo, Hours)
Dependent (ESSN, Dependent-name, Sex)
Write SQL queries to:
i. Retrieve the name of employees who have two or more
dependents.
ii. Retrieve the name of employees who are paid the same salary
as that of RAJ.
iii. Retrieve the name of employees and their SuperSSN name.

14.Consider the following database schema.


Sailors (sid, sname, rating, age)
Boats (bid, bname, color)
Reserves (sid, bid)
Write SQL queries to:
i. Find the names of sailors who have reserved a red boat.
ii. Find the names of sailors who have reserved a red or green
boat.
iii. Find the names of sailors who have reserved all boats called
Interlake.

15.Discuss how NULLs are treated in comparison operators in SQL. How are
NULLs treated when aggregate functions are applied in an SQL query? How
are NULLs treated if they exist in grouping attributes?

You might also like