Professional Documents
Culture Documents
P_Name20 Characters
DOJ Date
SAL NUMBER
i) Display the name of the programmer, which has the highest salary.
ii) Update the salary of all programmer by 2000 whose name start with letter 'R'.
4. Explain the concept of candidate keys with the help of an appropriate example.
5. Explain the concept of cartesian product between two tables, with the help of an appropriate
example.
6. What is primary and alternate key in a database? Give a suitable example to explain each.
7. What do you understand by primary key? Give a suitable example of the primary key from a table
containing some meaningful data.
8. What do you understand by normalization?
9. Consider the following relations
Teach (Name, Address, Course)
Give an expression in the relational algebra for each of the following:
(i) Print all the information about teachers who are teaching the 'DBMS' course.
(ii) Print the names and addresses of those teachers who teach 'computer'.
(iii) List all the teachers who live in Mumbai.
10. Observe the following table carefully and write the names of the most appropriate columns,
which can be considered as (i) candidate keys and (ii) primary key.
Table: Product
CI AMOUN
CNAME COUNTRY ITEM
D T
101 ALLE 100000 JMEKA SHOES
HELME
111 BEN 20000 FRANCE
T
110 RIKI 25000 AMERICA BAG
BRETT AUSTRALI
011 105000 BAT
LEE A
11. Answer the questions (a) and (b) on the basis of the following tables SHOPPE and
ACCESSORIES.
TABLE SHOPPE
Id SName Area
S001ABC ComputeronicsCP
S002All Infotech Media GK II
S003Tech Shoppe CP
S004Geeks Tecno Soft Nehru Place
S005Hitech Tech Store Nehru Place
TABLE ACCESSORIES
No Name Price Id
A01Mother Board12000S01
A02Hard Disk 5000 S01
A03Keyboard 500 S02
A04Mouse 300 S01
A05Mother Board13000S02
A06Keyboard 400 S03
A07LCD 6000 S04
T08 LCD 5500 S05
T09 Mouse 350 S05
T10 Hard Disk 4500 S03
(a) Write the SQL queries:
i) To display Name and price of all the Accessories in ascending order of their price.
(ii) To display id and Sname of all Shoppe located in Nehru place.
(iii) To display Minimum and Maximum price of each Name of Accessories.
(iv) To display Name,Price of all Accessories and their respective SName,where they are
available.
(b) Write the output of the following SQL commands;
(i) SELECT DISTINCT NAME FROM ACCESSORIES WHERE PRICE>=5000;
(ii)SELECT AREA.COUNT (*) FROM SHOPPE GROUP BY AREA;
(iii)SELECT COUNT (DISTINCT AREA) FROM SHOPPE;
(iv)SELECT NAME,PRICE*0.05 DISCOUNT FROM ACCESSORIES WHERESNO IN
('S02','S03');
12. Write SQL queries for (a) to (f) and write the output for the SQL queries mentioned in (g) parts (i)
to (iv) on the basis of tables ITEMS and TRADERS.
TABLE: ITEMS
TcodeTName City
T01 ELECTRONIC SALESMUMBAI
T03 BUSY STORE CORP DELHI
T02 DISP HOUSE INC CHENNAI
(a) To display the details of all the items in ascending order of item names(i.e. INAME).
(b) To display item name and price of all those items whose price is in the range of 10000 nd
22000(both values inclusive)
(c) To display the number of items, which are traded by each trader. The expected output of this
query should be:
T012
T031
T022
(d) To display the Price, item name(ie.name) and quantity(ie.Qty) of those items, which have
quantity more than 150.
(e) To display the names of those traders, who are either from DELHI or from MUMBAI.
(f) To display the name of the companies and the name of the items in descending order of
company names.
(g) Obtain the outputs of the following SQL queries based on the data given in the tables ITEMS
and TRADERS above.
(i) SELECT MAX(Price), MIN(Price) FROM ITEMS;
(ii) SELECT Price * Qty AMOUNT
FROM ITEMS WHERE Code=1004;
(iii) SELECT DISTINCT Tcode FROM ITEMS;
(iv) SELECT IName, TName
FROM ITEMS I, TRADERS T
WHERE I.Code=T.TCode AND Qty<100;6
13. Write SQL queries for (a) to (f) and write the outputs for (g) parts (i) to (iv) on the basis of tables
APPLICANTS and COURSES.
TABLE: APPLICANTS
C_IDCOURSES
A01 FASHION DESIGN
A02 NETWORKING
A03 HOTEL MANAGEMENT
A04 EVENT MANAGEMENT
A05 OFFICE MANAGEMENT
(a) To display NAME, FEE, Gender, JOINYEAR about the APPLICANTS, who have joined
before 2010.
(b) To display the names of applicants, who are paying FEE more than 30000.
(c) To display the names of all applicants in ascending order of their joinyear.
(d) To display the year and the total number of applicants joined in each year
from the table APPLICANTS>
(e) To display the C_ID and the number of applicants registered in the course
from the APPLICANTS table.
(f) To display the applicant's name with their respective course's name from the
tables APPLICANTS and COURSES.
(g) Give the output of the following SQL statements:
(i) SELECT NAME,JOINYEAR FROM APPLICANTS WHERE GENDER='F' AND C_ID='A02';
(ii) SELECT MIN(JOINYEAR) FROM APPLICANTS WHERE GENDER='M';
(iii) SELECT AVG(FEE) FROM APPLICANTS WHERE C_ID='A01' OR C_ID='A05';
(iv) SELECT SUM(FEE), C_ID FROM APPLICANTS GROUP BY C_ID HAVING COUNT(*)=2;
14. Write SQL commands for (a) to (f) and write the outputs for (g) on the basis of table STUDENT
TABLE: STUDENT
SNONAME STREAM FEES AGESEX
1 ARUN KUMAR COMPUTER 750.0017 M
2 DIVYA JENEJA COMPUTER 750.0018 F
3 KESHAR MEHRA BIOLOGY 500.0016 M
4 HARISH SINGH ENG.DR 350.0018 M
5 PRACHI ECONOMICS300.0019 F
6 NISHA ARORA COMPUTER 750.0015 F
7 DEEPAK KUMAR ECONOMICS300.0016 M
8 SARIKA VASWANIBIOLOGY 500.0015 F
(a) List the name of all students, who have taken stream as COMPUTER.
(b) To count the number of female students.
(c) To display the number of students stream wise.
(d) To insert a new row in the STUDENT table
9,'KARISHMA','ECONOMICS',300.18,'F'
(e) To display a report, listing NAME, STREAM,SEX and stipend, where stipend is 20% of fees.
(f) To display all the records in sorted order of name.
(g) Give the output of the following SQL statements based on STUDENT table:
(i) SELECT AVG(FEES) FROM STUDENT WHERE STREAM='COMPUTER';
(ii) SELECT MAX(AGE) FROM STUDENT;
(iii) SELECT COUNT(DISTINCT STREAM) FROM STUDENT;
(iv) SELECT SUM(FEES) FROM STUDENT GROUP BY STREAM;
15. Write SQL commands for (a) to (d) and write the outputs for (e) and (f) on the basis of table
EMPLOYEE
TABLE: EMPLOYEE