sql assignment
sql assignment
COMPUTER SCIENCE(083)
ASSIGNMENT III
Q1. Which sql command is used to add a new attribute in a table?
Q2. Which SQL aggregate function is used to count all records of a table ?
Q3. Which clause is used with a SELECT command in SQL to display the records in ascending order of an
attribute ?
Q4. Write the full form of the following abbreviations : (i) DDL (ii) DML
Q5. Observe the following tables, EMPLOYEES and DEPARTMENT carefully and answer the questions that
follow :
(i).What is the Degree of the table EMPLOYEES ? What is the cardinality of the table DEPARTMENT ?
(ii) What is a Primary Key ? Explain.
Q6. Differentiate between Selection and Projection operations in context of a Relational Database. Also,
illustrate the difference with one supporting example of each.
Q7. In SQL, write the name of the aggregate function which will display the cardinality of a
table.
Q8. Which of the following clauses in SQL is most appropriate to use to select matching tuples
in a specific range of values ?
A) IN B). LIKE C). BETWEEN D). IS
Q11. Which of the following commands in SQL is used to add a new record into a table ?
A). ADD B).INSERT C). UPDATE D). NEW
Q12. Which of the following is the correct expansion of DML in context of SQL ?
A). Direct Machine Language B). Data Mixing Language
C). Distributed Machine Language D). Data Manipulation Language
Q13. 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
(c) Anmol has received a new medicine to be added into his stock, but for which he does not know the
number of UNITS. So he decides to add the medicine without its value for UNITS. The rest of the
values are as follows :
MID MNAME PRICE EXPIRY
M7 SUCRALFATE 17 2022-03-20
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
Q14.What are Tuples in a SQL Table ? Write a suitable example with a SQL Table to
illustrate your answer.
Q15.Differentiate between Primary Key and Candidate Key in the context of Relational Database Model.
(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.