

MCQOPTIONS
Saved Bookmarks
This section includes 82 Mcqs, each offering curated multiple-choice questions to sharpen your Structured Query Language (SQL) knowledge and support exam preparation. Choose a topic below to get started.
1. |
Given the following two statements about SQL(a) An SQL query can contain HAVING clause only if it has GROUP BY clause.(b) In an SQL query “SELECT_FROM_WHERE_GROUP BY_HAVING”, HAVING is executed before WHERE.Which of the following is correct? |
A. | (a) and (b) are true |
B. | (a) is true, (b) is false |
C. | (a) is false, (b) is true |
D. | (a) and (b) both are false |
Answer» C. (a) is false, (b) is true | |
2. |
Consider the following statements S1 and S2 about the relational data model:S1: A relation scheme can have at most one foreign key.S2: A foreign key in a relation scheme R cannot be used to refer to tuples of R.Which one of the following choices is correct? |
A. | S1 is true and S2 is false. |
B. | Both S1 and S2 are true. |
C. | Both S1 and S2 are false. |
D. | S1 is false and S2 is true. |
Answer» D. S1 is false and S2 is true. | |
3. |
_______ SQL command changes one or more fields in a record. |
A. | LOOK-UP |
B. | INSERT |
C. | MODIFY |
D. | CHANGE |
Answer» D. CHANGE | |
4. |
Consider the following SQL query:SELECT title, nameFROM EmployeeORDER BY title, name DESC:In output of above query the different titles are listed in ___________ order the names of employees having same title are listed in ___________ order. |
A. | Ascending, Ascending |
B. | Ascending, Descending |
C. | Descending, Ascending |
D. | Descending, Descending |
Answer» C. Descending, Ascending | |
5. |
_______ symbol is used to see every column of a table. |
A. | / |
B. | _ _ |
C. | * |
D. | ! |
Answer» D. ! | |
6. |
Consider a relational table with a single record for each enrolled student with the following attributes1. Eno: Unique enrollment number for each enrolled student2. UID: Unique identity number at the national level for each citizen3. Acc_no: Unique account number at the bank. A student can have multiple accounts or joint accounts.. This attributes stores the primary account number.4. Name: Name of the student5. Phone: Phone number of the studentWhich of the following options is incorrect? |
A. | Acc_no is candidate key |
B. | ENo can be a primary key |
C. | UID is a candidate key, if all students are from the same country |
D. | If S is a superkey such that S ∩ UID is Null then S U UID is also a super key |
Answer» B. ENo can be a primary key | |
7. |
Consider a relational database containing the following schemes.CataloguesnopnoCostS1P1150S1P250S1P3100S2P4200S2P5250S3P1250S3P2150S3P5300S3P4250 SupplierssnosnamelocationS1M/s Royal furnitureDelhiS2M/s Balaji furnitureBangaloreS3M/s Premium furnitureChennai PartspnoPnamePart_specP1TableWoodP2ChairWoodP3TableSteelP4AlmirahSteelP5AlmirahWood The primary key of each table is indicated by underling the constituent fields.SELECT s.sno, s.snameFROM Suppliers s, Cataloque cWHERE s.sno = c.sno AND Cost > (SELECT AVG (cost)FROM CataloqueWHERE pno = ‘P4’GROUP BY pno);The number of rows returned by the above SQL query is |
A. | 4 |
B. | 5 |
C. | 0 |
D. | 2 |
Answer» B. 5 | |
8. |
Given two relations R1(A, B) and R2(C, D), the result of following querySelect distinct A, Bfrom R1, R2is guaranteed to be same as R1 provided one of the following condition is satisfied. |
A. | R1 has no duplicates and R2 is empty. |
B. | R1 has no duplicates and R2 is non-empty. |
C. | Both R1 and R2 have no duplicates. |
D. | R2 has no duplicates and R1 is non - empty |
Answer» B. R1 has no duplicates and R2 is non-empty. | |
9. |
Consider the following schema :Sailors(sid, sname, rating, age)Boats(bid, bname, colour)Reserves(sid, bid, day)Two boats can have the same name but the colour differentiates them.The two relationsρ(Tempsids, (πsid, bid Reserves) / (πbid (σname = ‘Ganga' Boats))),πsname (Tempsids ⋈ Sailors)If / is division operation, the above set of relations represents the query |
A. | Names of sailors who have reserved all boats called Ganga |
B. | Names of sailors who have not reserved any Ganga boat |
C. | Names of sailors who have reserved at least one Ganga boat |
D. | Names of sailors who have reserved at most one Ganga boat |
Answer» B. Names of sailors who have not reserved any Ganga boat | |
10. |
A minimal super key (i.e., one of the super keys for which no proper subset is a super key) is called: |
A. | Super Key |
B. | Candidate Key |
C. | Primary Key |
D. | Both Candidate and Primary Key |
Answer» E. | |
11. |
In context of a relation in database, choose a false statement: |
A. | There can be more than one super keys. |
B. | A candidate key is a minimal super key. |
C. | One of the candidate keys is designated as primary key. |
D. | Primary key is obtained by removing one or more attributes from a candidate key. |
Answer» E. | |
12. |
Immunity of the external schemas (or application programs) to changes in the conceptual schema is referred to as: |
A. | Physical Data Independence |
B. | Logical Data Independence |
C. | Both 1) and (b) |
D. | None of the above |
Answer» C. Both 1) and (b) | |
13. |
______ command provides a window through which one can see the data of another table. |
A. | SELECT |
B. | CREATE VIEW |
C. | CREATE |
D. | All options are wrong |
Answer» C. CREATE | |
14. |
______ constraint is specified between two relations and is used to maintain the consistency among tuples of the two relations. |
A. | Entity integrity |
B. | Referential integrity |
C. | Primary key |
D. | Unique key |
Answer» C. Primary key | |
15. |
Consider the following relation.Cinema (theater, address, capacity)Which of the following options will be needed at the end of the SQL querySELECT P1.addressFROM Cinema P1such that it always finds the addresses of theaters with maximum capacity? |
A. | WHERE P1.capacity >= All (select P2.capacity from Cinema P2) |
B. | WHERE P1.capacity >= Any (select P2.capacity from Cinema P2) |
C. | WHERE P1.capacity > All (select max(P2.capacity) from Cinema P2) |
D. | WHERE P1.capacity > Any (select max(P2.capacity) from Cinema P2) |
Answer» B. WHERE P1.capacity >= Any (select P2.capacity from Cinema P2) | |
16. |
An instance of relational schema R(A, B, C) has distinct values of A including NULL values. Which one of the following is true? |
A. | A is candidate key |
B. | A is not a candidate key |
C. | A is a primary key |
D. | Both "A is a candidate key" and "A is a primary key" |
Answer» B. A is not a candidate key | |
17. |
Assume that AB → C, C → D and D → A are simultaneously satisfied by a relation r(R). What are the candidate keys of this relation? |
A. | AB, CD and AD |
B. | AB and CD |
C. | AB and DB |
D. | ABCD and BC |
Answer» D. ABCD and BC | |
18. |
Consider the following table in a relational databaseLast NameRankRoomShiftSmithManager234MorningJonesCustodian33MorningSmithCustodian33EveningDoeClerical222MorningAccording to the data shown in the table, which of the following could be a candidate key of the table? |
A. | {Last Name} |
B. | {Room} |
C. | {Shift} |
D. | {Room, Shift} |
Answer» E. | |
19. |
In SQL decimal data type, _______ indicates the maximum number of digits to the right of decimal point. |
A. | Float |
B. | Scale |
C. | Fraction |
D. | Precision |
Answer» C. Fraction | |
20. |
Let relation R2 has a Foreign Key that refers to Primary Key of relation R1. Which of the following operations may cause violation of referential integrity constraints?I: insert into R1II: insert into R2III: delete from R1IV: delete from R2 |
A. | II and III |
B. | I and IV |
C. | I, II and III |
D. | III and IV |
Answer» B. I and IV | |
21. |
Consider the relations r(A, B) and s(B, C), where s.B is a primary key and r.B is a foreign key referencing s.B. Consider the queryQ: |
A. | 𝜎𝐵<5(𝑟 ⋈ 𝑠) |
B. | 𝜎𝐵<5(𝑟 𝐿𝑂𝐽 𝑠) |
C. | 𝑟 𝐿𝑂𝐽 (𝜎𝐵<5(𝑠)) |
D. | 𝜎𝐵<5(𝑟) 𝐿𝑂𝐽 𝑠 |
Answer» D. 𝜎𝐵<5(𝑟) 𝐿𝑂𝐽 𝑠 | |
22. |
Given relations R(w, x) and S(y, z), the result of SELECT DISTINCT w, x from R, S is guaranteed to be same as R, provided. |
A. | R has no duplicates and S is non-empty |
B. | R and S have no duplicates |
C. | S has no duplicates and R is non-empty |
D. | R and S has same number of tuples |
Answer» B. R and S have no duplicates | |
23. |
Let for any relation R. IR represents operation insert into R and DR represents operation delete from R. Assume that a relation R2 has a foreign key that refers to primary key of another relation R1. Two operations that may cause violation of referential integrity constraints are: |
A. | IR1 and IR2 |
B. | DR1 and DR2 |
C. | IR1 and DR2 |
D. | IR2 and DR1 |
Answer» E. | |
24. |
______ clause allows sorting of query results by one or more columns. |
A. | DISTINCT |
B. | ALL |
C. | WHERE |
D. | ORDER BY |
Answer» E. | |
25. |
_______ key must satisfy referential integrity in a relation, while _______ key must satisfy entity integrity. |
A. | Candidate, primary |
B. | Foreign, primary |
C. | Primary, foreign |
D. | Foreign, superkey |
Answer» C. Primary, foreign | |
26. |
Given the following schema:employees(emp-id, first-name, last-name, hire-date,dept-id, salary)departments(dept-id, dept-name, manager-id, location-id)You want to display the last names and hire dates of all latest hires in their respective departmentsin the location ID 1700. You issue the following query:SQL>SELECT last-name, hire-dateFROM employeesWHERE (dept-id, hire-date) IN(SELECT dept-id, MAX(hire-date)FROM employees JOIN departments USING(dept-id)WHERE location-id = 1700GROUP BY dept-id);What is the outcome? |
A. | It executes but does not give the correct result |
B. | It executes and gives the correct result. |
C. | It generates an error because of pairwise comparison |
D. | It generates an error because the GROUP BY clause cannot be used with table joins in a subquery. |
Answer» C. It generates an error because of pairwise comparison | |
27. |
On the basis of above given table structures, retrieve the distinct employee ID (EMPID) of all employees of university who are working on project No.20, 30 and 40. |
A. | SELECT EMPIDFROM PROJECTWORKWHERE PROJNO=(20, 30, 40); |
B. | SELECT EMPIDFROM PROJECTWOREKWHERE PROJNO IN (20, 30, 40); |
C. | SELECT DISTINCT EMPIDFROM PROJECTWORKWHERE PROJNO IN (20, 30, 40); |
D. | SELECT DISTINCT EMPIDFROM PROJECTWORKWHERE PROJNO=20, 30, 40; |
Answer» D. SELECT DISTINCT EMPIDFROM PROJECTWORKWHERE PROJNO=20, 30, 40; | |
28. |
Consider the following relational schema.Students(rollno: integer, sname: string)Courses(courseno: integer, cname: string)Registration(rollno: integer, courseno: integer, percent: real)Which of the following queries are equivalent to this query in English?“Find the distinct names of all students who score more than 90% in the course numbered 107”(I) SELECT DISTINCT S.snameFROM Students as S, Registration as RWHERE R.rollno=S.rollno AND R.courseno=107 AND R.percent >90(II) Πsname(σcourseno=107 percent>90 (Registration Students))(III) {T | tudents, Registration ( S.rollno=R.rollnoR.courseno=107 R.percent>90 T.sname=S.sname)}(IV) {N> | ∃SR∃RP ( R, SN> ∈ Students ∧ R, 107, RP>∈ Registration ∧ RP>90)} |
A. | I, II, III and IV |
B. | I, II and III only |
C. | I, II and IV only |
D. | II, III and IV only |
Answer» B. I, II and III only | |
29. |
A ______ is the combination of one or more column values in a table that make a row of data unique within the table. |
A. | foreign key |
B. | primary key |
C. | candidate key |
D. | natural key |
Answer» D. natural key | |
30. |
In SQL, the _______ command is used to recompile view. |
A. | CREATE VIEW |
B. | COMPILE VIEW |
C. | ALTER VIEW |
D. | DEFINE VIEW |
Answer» D. DEFINE VIEW | |
31. |
Consider the following two tables and four queries in SQL.Book (isbn, bname), Stock (isbn, copies)Query 1: SELECT B.isbn, S.copiesFROM Book B INNER JOIN Stock SON B.isbn = S.isbn; Query 2: SELECT B.isbn, S.copiesFROM Book B LEFT OUTER JOIN Stock SON B.isbn = S.isbn;Query 3: SELECT B.isbn, S.copiesFROM Book B RIGHT OUTER JOIN Stock SON B.isbn = S.isbn; Query 4: SELECT B.isbn, S.copiesFROM Book B FULL OUTER JOIN Stock SON B.isbn = S.isbn; Which one of the queries above is certain to have an output that is a superset of the outputsof the other three queries? |
A. | Query 1 |
B. | Query 2 |
C. | Query 3 |
D. | Query 4 |
Answer» E. | |
32. |
Let x, y, z, a, b, c be the attributes of an entity set E. If {x}, {x, y}, {a, b}, {a, b, c}, {x, y, z} are superkeys then which of the following are the candidate keys ? |
A. | {x, y} and {a, b} |
B. | {x} and {a, b} |
C. | {x, y, z} and {a, b, c} |
D. | {z} and {c} |
Answer» C. {x, y, z} and {a, b, c} | |
33. |
A ________ of a relation is a set of one or more attributes whose values are guaranteed to identify tuples in the relation uniquely. |
A. | super key |
B. | key |
C. | foreign key |
D. | scheme |
Answer» B. key | |
34. |
In SQL, _______ is an Aggregate function. |
A. | SELECT |
B. | CREATE |
C. | AVG |
D. | MODIFY |
Answer» D. MODIFY | |
35. |
______ SQL command allows to make queries on the database |
A. | DELETE |
B. | SELECT |
C. | CREATE |
D. | DROP |
Answer» C. CREATE | |
36. |
Given the relationsemployee (name, salary, deptno) anddepartment (deptno, deptname, address)Which of the following queries cannot be expressed using the basic relational algebra operations (U, -, x, π, σ, p)? |
A. | Department address of every employee |
B. | Employees whose name is the same as their department name |
C. | The sum of all employees' salaries |
D. | All employees of a given department |
Answer» D. All employees of a given department | |
37. |
Let R = (A, B, C, D, E, F) be a relation scheme with the following dependencies C → F, E → A, EC → D, A → B. Which of the following is a key for R ? |
A. | CD |
B. | EC |
C. | AE |
D. | AC |
Answer» C. AE | |
38. |
A trigger has three parts.The ________ describes the change that activates the trigger.The ________ is a query that is run whenever the trigger is activated.The ________ is the procedure that is executed if the trigger is activated and the condition is true. |
A. | event, condition, actor |
B. | entity, condition, action |
C. | event, condition, action |
D. | event, question, action |
Answer» D. event, question, action | |
39. |
If D1, D2,...,Dn, are domains in a relational model, then the relation is a table, which is a subset of |
A. | D1 ⊕ D2 ⊕ .... ⊕ Dn |
B. | D1 × D2 × ...× Dn |
C. | D1 ∪ D2 ∪ ...∪ Dn |
D. | D1 ∩ D2 ∩ ...∩ Dn |
Answer» C. D1 ∪ D2 ∪ ...∪ Dn | |
40. |
Consider the following relational query on the above database:SELECT S.snameFROM Suppliers S WHERE S.sid NOT IN (SELECT C.sidFROM Catalog CWHERE C.pid NOT IN (SELECT P.pidFROM Parts PWHERE P.color < > ‘blue’))Assume that relations corresponding to the above schema are not empty. Which of the following is the correct interpretation of the above query? |
A. | Find the names of all suppliers who have supplied a non-blue part |
B. | Find the names of all suppliers who have not supplied a non-blue part |
C. | Find the names of all suppliers who have supplied only blue parts |
D. | Find the names of all suppliers who have not supplied only blue parts |
Answer» E. | |
41. |
Consider the following schema:Emp (Empcode, Name, Sex, Salary, Deptt)A simple SQL query is executed as follows :SELECT Deptt FROM EmpWHERE sex = ‘M’GROUP by DeptHaving avg (Salary) > { select avg (Salary) from Emp}The output will be |
A. | Average salary of male employee is the average salary of the organization |
B. | Average salary of male employee is less than the average salary of the organization |
C. | Average salary of male employee is equal to the average salary of the organization |
D. | Average salary of male employees is more than the average salary of the organization |
Answer» E. | |
42. |
In a relational database model, cardinality of a relation means |
A. | The number of tuples |
B. | The number of tables |
C. | The number of attributes |
D. | The number of constraints |
Answer» B. The number of tables | |
43. |
In the following procedureInteger procedure P(X, Y);Integer X, Y;value x;begin K = 5; L = 8; P = x + y;endX is called by value and Y is called by name. If the procedure were invoked by the following program fragment K = 0; L = 0; Z = P(K,L);Then the value Z would be set equal to |
A. | 5 |
B. | 8 |
C. | 13 |
D. | 0 |
Answer» C. 13 | |
44. |
In SQL – the function - avg, min, max, sum, count are called as _______. |
A. | aggregate function |
B. | adjunct function |
C. | set operation |
D. | scalar operation |
Answer» B. adjunct function | |
45. |
_____ attribute is used to restart the numbering in an ordered list. |
A. | Type |
B. | Order |
C. | Start |
D. | Number |
Answer» D. Number | |
46. |
Consider the relation scheme R = (E, F, G, H, I, J, K, L, M, N) and the set of functional dependencies {(E, F} → {G}, {F} → {I, J}, {E, H} → {K, L}, {K} → {M}, {L} → {N}} on R. What is the key for R ? |
A. | {E, F} |
B. | {E, F, H} |
C. | {E, F, H, K, L} |
D. | {E} |
Answer» C. {E, F, H, K, L} | |
47. |
A _______ is a pictorial depiction of the schema of a database that shows the relations in the database, their attributes, and primary keys and foreign keys. |
A. | relational algebra |
B. | schema diagram |
C. | relational query languages |
D. | flow diagram |
Answer» C. relational query languages | |
48. |
An expression in the domain relational calculus is of the form: |
A. | \(\lbrace P(x_1, x_2,..., x_n)|\rbrace\) |
B. | \(\lbrace x_1, x_2, ..., x_n | < x_1, x_2, ..., x_n >\rbrace\) |
C. | \(\lbrace x_1, x_2, ..., x_n | x_1, x_2, ..., x_n \rbrace\) |
D. | \(\lbrace < x_1, x_2, ..., x_n > | P(x_1, x_2, ..., x_n)\rbrace\) |
Answer» E. | |
49. |
Let P be a procedure that for some inputs calls itself ( i.e. is recursive ). If P is guaranteed to terminate, which of the following statement(s) must be true?I. P has a local variablell. P has an execution path where it does not call itselfII. P either refers to a global variable or has at least one parameter |
A. | I only |
B. | II only |
C. | III only |
D. | II and III only |
Answer» E. | |
50. |
Consider the following SQL query to retrieve ecode of employees from EMPLOYEE table, whose address contains 'INDIA':SELECT ecodeFROM EMPLOYEEWHERE _________;Which of the following is most suitable to complete the query? |
A. | address LIKE '_INDIA_' |
B. | address = %INDIA% |
C. | address AS '%INDIA_' |
D. | address LIKE '%INDIA%' |
Answer» E. | |