0% found this document useful (0 votes)
12 views8 pages

First Terms QL QN

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views8 pages

First Terms QL QN

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Class 12 Computer Science (CS083)

Worksheet 2 (Database Management)


1) Which of the following statements is FALSE about keys in a relational database? a.
Any candidate key is eligible to become a primary key.
b. A primary key uniquely identifies the tuples in a relation.
c. A candidate key that is not a primary key is a foreign key.
d. A foreign key is an attribute whose value is derived from the primary key of
another relation.
2) ______ command is used to remove primary key from a table in SQL.
(a) update (b)remove (c) alter (d)drop

3) ______ command is used to add a new attribute in an existing table.


(a) update (b)insert (c) alter (d)create

4) ______ command is used to add a new tuple in an existing table.


(a) update (b)insert (c) alter (d)create

5) Categorize the following as DDL or DML:

a) UPDATE b) ALTER c) INSERT d) DELETE

6) All the attributes that can be used to uniquely identify the tuples in the relation (can serve
as a primary key) is called the _________.

7) Give MySQL command/s for the following: 3

a) To check the structure of the table STUDENT

b) To list the names of tables in the database EMPLOYEE

c) To remove the primary key, EMPID from the table EMP

8) A result set is extracted from the database using the cursor object (that has been already
created) by giving the following statement.

Mydata=cursor.fetchone()

(a) How many records will be returned by fetchone() method?

(b) What will be the datatype of Mydata object after the given command is executed?

9) Which command is given to save the changes permanently in the database after performing
update and delete queries in interface.

10) A resultset is extracted from the database using the cursor object(that has been
already created) by giving the following statement.

Myobject.fetchmany(5)
(a) How many records will be returned by fetchmany() method?

(b) What will be the data type of Myobject after the given command is executed?

11) Consider the table CLUB given below and write the output of the SQL queries
that follow:

(i) SELECT COUNT(DISTINCT SPORTS) FROM CLUB;

(ii) SELECT CNAME, SPORTS FROM CLUB WHERE DOAPP<"2006-04-30" AND


CNAME LIKE "%NA";

(iii) SELECT CNAME, AGE, PAY FROM CLUB WHERE GENDER = "MALE" AND
PAY BETWEEN 1000 AND 1200;

12)
13)
Sartaj, now wants to display the records of students whose fee is more than 5000. Help Sartaj
to write the program in Python.

14) Write the outputs of the SQL queries (i) to (iii) based on the relations Teacher and
Placement given below:
(i) SELECT Department, avg(salary) FROM Teacher GROUP BY Department;

(ii) SELECT MAX(Date_of_Join),MIN(Date_of_Join) FROM Teacher;

(iii)SELECT Name, Salary, T.Department, Place FROM Teacher T, Placement P WHERE


T.Department = P.Department AND Salary>20000;

(iv)SELECT Name, Place FROM Teacher T, Placement P WHERE Gender='F' and


T.Department=P.Department;

15) Navdeep creates a table RESULT with a set of records to maintain the marks secured by
students in Sem 1, Sem2, Sem3 and their division. After creation of the table, he has entered
data of 7 students in the table.

Table: RESULT
Based on the data given above answer the following questions:

i. Identify the most appropriate column, which can be considered as Primary key.

ii. If two columns are added and 2 rows are deleted from the table result, what will be the
new degree and cardinality of the above table?

iii. Write the statements to: a. Insert the following record into the table – Roll No- 108,
NameAadit, Sem1- 470, Sem2-444, Sem3-475, Div – I. b. Increase the SEM2 marks of the
students by 3% whose name begins with ‘N’.

iv) Write the statements to: a. Delete the record of students securing IV division. b. Add a
column REMARKS in the table with datatype as varchar with 50 characters
16)
Write SQL queries for the following:
(i) Display product name and brand name from the tables PRODUCT and BRAND.
(ii) Display the structure of the table PRODUCT.
(iii) Display the average rating of Medimix and Dove brands
(iv) Display the name, price, and rating of products in descending order of rating.
17) Write SQL queries for (i) to (v), which are based on the table: SCHOOL and ADMIN

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy