Monday, 11 January 2021

MYSQL Qus

 MYSQL Qus


1. 

Consider a relation book (title, price) which contains the titles and prices of different books. Assuming that no two books have the same price, what does the following SQL query list ?

Select title

from book as B

where (select count ( * )

from book as T

where T.price > B.price) < 7


  • Titles of the six most expensive books.
  • Title of the sixth most expensive books.
  • Titles of the seven most expensive books.
  • Title of the seventh most expensive books.

2. 

Consider the following schema:

Emp (Empcode, Name, Sex, Salary, Deptt)
A simple SQL query is executed as follows:
SELECT Deptt FROM Emp
WHERE sex = 'M'
GROUP by Dept
Having avg (Salary) > (select avg (Salary) from Emp)
  • Average salary of male employee is the average salary of the organization
  • Average salary of male employee is less than the average salary of the organization
  • Average salary of male employee is equal to the average salary of the organization
  • Average salary of male employee is more than the average salary of the organization


3. 

The output will be

The STUDENT information in a university stored in the relation STUDENT (Name, SEX, Marks, DEPT_Name) 

Consider the following SQL Query SELECT DEPT_Name from STUDENT where SEX = 'M' group by DEPT_Name having avg (Marks)>SELECT avg (Marks) from STUDENT. 

It Returns the Name of the Department for which:


  • The Average marks of Male students is more than the average marks of students in the same Department
  • The average marks of male students is more than the average marks of students in the University
  • The average marks of male students is more than the average marks of male students in the University
  • The average marks of students is more than the average marks of male students in the University


4. 

Which of the following is/are true with reference to ‘view’ in DBMS ? 
(a) A ‘view’ is a special stored procedure executed when certain event occurs. 

(b) A ‘view’ is a virtual table, which occurs after executing a pre-compiled query. code:

  • Only (a) is true
  • Only (b) is true
  • Both (a) and (b) are true
  • Neither (a) nor (b) are true

5. 

Given two relations R1(A, B) and R2(C, D), the result of following query

Select distinct A, B from R1, R2

is guaranteed to be same as R1 provided one of the following condition is satisfied.


  • R1 has no duplicates and R2 is empty.
  • R1 has no duplicates and R2 is non - empty.
  • Both R1 and R2 have no duplicates.
  • R2 has no duplicates and R1 is non - empty.

6. 

Consider the relations r1(P, Q, R) and r2(R, S, T) with primary keys P and R respectively. The relation r1 contains 2000 tuples and r2 contains 2500 tuples. The maximum size of the natural join

  • 2000
  • 2500
  • 4500
  • 5000

7.
Which of the following is/are correct?

  • An SQL query automatically eliminates the duplicates
  • An SQL query will not work if there are no indexes on the relations
  • SQL permits attribute names to be repeated in the same relation
  • None of the above

No comments:

Post a Comment