document_1000000562
document_1000000562
1. Anmol maintains that database of Medicines for his pharmacy using SQL to store the data. The structure of
the table PHARMA for the purpose is as follows :
Name of the table – PHARMA. The attributes of PHARMA are as follows :
MID – numeric, MNAME - character of size 20, PRICE – numeric, UNITS – numeric, EXPIRY – date
Write the SQL command which Anmol should execute to perform the required task.
(d) Anmol wants to change the name of the attribute UNITS to QUANTITY in the table PHARMA. Which of the
following commands will he use for the purpose?
(i) UPDATE (ii) DROP TABLE (iii) CREATE TABLE (iv) ALTER TABLE
(e) Now Anmol wants to increase the PRICE of all medicines by 5. Which of the following commands will he
use for the purpose?
(i) UPDATE SET (ii) INCREASE BY (iii) ALTER TABLE (iv) INSERT INTO
2. Write the outputs of the SQL queries (i) to (iii) based on the relations CUSTOMER and TRANSACTION given
below :
3. Write SQL statements for the following queries (i) to (v) based on the relations CUSTOMER and
TRANSACTION given below :
(a) To display all information about the CUSTOMERS whose NAME starts with 'A'.
(b) To display the NAME and BALANCE of Female CUSTOMERS (with GENDER as 'F') whose TRANSACTION
Date (TDATE) is in the year 2019.
(c) To display the total number of CUSTOMERS for each GENDER.
(d) To display the CUSTOMER NAME and BALANCE in ascending order of GENDER.
(e) To display CUSTOMER NAME and their respective INTEREST for all CUSTOMERs where INTEREST is
calculated as 8% of BALANCE.
4. A departmental store MyStore is considering to maintain their inventory using SQL to store the data. As a
database administer, Abhay has decided that :
• Name of the database - mystore
• Name of the table - STORE
• The attributes of STORE are as follows:
ItemNo – numeric, ItemName – character of size 20 , Scode – numeric, Quantity – numeric
iii. To list the names of all teachers with their date of joining in ascending order.
iv. To display teacher’s name, salary, age for male teachers only.
v. To display name, bonus for each teacher where bonus is 10% of salary.
vi. To display name, department and place of posting of all teachers.
6. Consider the table, MOVIEDETAILS given below:
Table: MOVIEDETAILS
Which field will be considered as the foreign key if the tables MOVIEDETAILS and SCHEDULE are related in a
database?
7. A table, ITEM has been created in a database with the following fields:
ITEMCODE, ITEMNAME, QTY, PRICE
Give the SQL command to add a new field, DISCOUNT (of type Integer) to the ITEM table.
8. Categorize following commands into DDL and DML commands?
INSERT INTO, DROP TABLE, ALTER TABLE, UPDATE...SET
9. Write queries (a) to (d) based on the tables EMPLOYEE and DEPARTMENT given below:
(a) To display the average salary of all employees, department wise.
(b) To display name and respective department name of each employee whose salary is more than 50000.
(c) To display the names of employees whose salary is not known, in alphabetical order.
10. Write the output of SQL queries (a) and (b) based on the following two tables DOCTOR and PATIENT
belonging to the same database
11. A SQL table ITEMS contains the following columns: INO, INAME, QUANTITY, PRICE, DISCOUNT
Write the SQL command to remove the column DISCOUNT from the table.
12. Write SQL queries for (a) to (d) based on the tables PASSENGER and FLIGHY given below.
13. Write the output of the SQL queries (a) to (d) based on the table VACCINATION_DATA given below:
14. Write the output of the SQL queries (a) and (b) based on the following two tables FLIGHT and PASSENGER
belonging to the same database :
Table : BATSMEN
(i) Identify and write the name of the Candidate Keys in the given table BATSMEN.
(ii) How many tuples are there in the given table BATSMEN ?
16. Write SQL queries for (a) to (d) based on the tables CUSTOMER and TRANSACT given below :
(a) Write the SQL statements to delete the records from table TRANSACT whose amount is less than 1000.
(b) Write a query to display the total AMOUNT of all DEBITs and all CREDITs.
(c) Write a query to display the NAME and corresponding AMOUNT of all CUSTOMERs who made a
transaction type (TTYPE) of CREDIT.
(d) Write the SQL statement to change the Phone number of customer whose CNO is 1002 to 9988117700 in
the table CUSTOMER.
17. (a) Write the outputs of the SQL queries (i) to (iv) based on the relations Teacher and Placement given
below:
Table : Teacher
19 .
20.
21.
22.
23. Consider the table CLUB given below and write the output of the SQL queries that follow.
Based on the given table, write SQL queries for the following:
(i) Increase the salary by 5% of personals whose allowance is known.
(ii) Display Name and Total Salary (sum of Salary and Allowance) of all personals. The
column heading ‘Total Salary’ should also be displayed.
(iii) Delete the record of personals who have salary greater than 25000
25. Consider the tables PRODUCT and BRAND given below:
Table: PRODUCT