227 DBMS & SQL (Computer Science) questions asked in DSSSB TGT / PGT previous year papers, each with the correct answer and explanation. Read them free on UTpaper, or attempt the full papers as timed online tests.
Name the tag and the attribute to be used to change the sequence of the list items in an ordered list from numbers to upper case letters
ATag-<OL>, Attribute - START
BTag-<OL>, Attribute - VALUE
CTag-<OL>, Attribute - TYPE
DTag-<OL>, Attribute - CASE
Show answerHide answer
Correct answer: (C) Tag-<OL>, Attribute - TYPE
Explanation
The TYPE attribute of <OL> sets the numbering style; TYPE="A" gives upper-case letters (A, B, C...). START only sets the starting value, and VALUE belongs to <LI>.
This question is based on the following SQL Table.
Mr. Aman, a Computer Science Teacher maintains the details of his class 12 Students is a SQL table as follow :
Table Name : MYSTUDENT
ROLLNO | NAME | SEC | MARKS
80105 | MARIA | A | 83.0
80108 | AMAR | B | 44.0
80109 | MANPREET | A | 92.0
80112 | SAMEER | A | 81.0
80115 | AKBAR | B | NULL
Identify the most Suitable Command to display the merit List of his students where the details will be displayed in descending order of their marks. If some students have same MARKs, their detail will be displayed in ascending order of their ROLLNO.
ASELECT * FROM MYSTUDENT ORDER BY DESC MARKS, ASC ROLLNO;
BSELECT * FROM MYSTUDENT ORDER BY MARKS DESC, ROLLNO ASC;
CSELECT * FROM MYSTUDENT ORDER BY MARKS; ROLLNO DESC, ASC;
DSELECT * FROM MYSTUDENT ORDER BY MARKS DESC; ROLLNO ASC;
Show answerHide answer
Correct answer: (B) SELECT * FROM MYSTUDENT ORDER BY MARKS DESC, ROLLNO ASC;
Explanation
ORDER BY takes the column first and the direction after it, separated by commas: ORDER BY MARKS DESC, ROLLNO ASC sorts by marks high to low and breaks ties by roll number ascending. The other options have wrong syntax.
This question is based on the following SQL Table.
Mr. Aman, a Computer Science Teacher maintains the details of his class 12 Students is a SQL table as follow :
Table Name : MYSTUDENT
ROLLNO | NAME | SEC | MARKS
80105 | MARIA | A | 83.0
80108 | AMAR | B | 44.0
80109 | MANPREET | A | 92.0
80112 | SAMEER | A | 81.0
80115 | AKBAR | B | NULL
Which of the following command can display the SEC wise Average of the student ?
ASELECT SEC, AVG (MARKS) FROM MYSTUDENT ORDER BY SEC;
BSELECT SEC, AVG (MARKS) FROM MYSTUDENT GROUP BY MARKS;
CSELECT *SEC, AVG (MARKS) FROM MYSTUDENT GROUP BY SEC;
DSELECT AVG (MARKS) FROM MYSTUDENT ORDER BY SEC;
Show answerHide answer
Correct answer: (C) SELECT *SEC, AVG (MARKS) FROM MYSTUDENT GROUP BY SEC;
Explanation
Section-wise averages need GROUP BY SEC with SELECT SEC, AVG(MARKS); ORDER BY only sorts and does not form groups, and GROUP BY MARKS groups the wrong column. Option C is the intended query (the "*" is a printing slip).
Consider two database relations R and S having 3 tuples in R and 2 tuples in S. What is the maximum number of tuples that could appear in the natural join of R and S?
A6
B2
C3
D5
Show answerHide answer
Correct answer: (A) 6
Explanation
At most, the natural join can produce every combination, as when there are no common attributes or every row shares the same common value. That is 3 × 2 = 6 tuples.
File operations that manipulate the 'open-count' maintained for each entry in open-file table include:
AOpen, write
BRead, write
CWrite, close
DOpen, close
Show answerHide answer
Correct answer: (D) Open, close
Explanation
The open-count records how many processes have the file open. open() increments it and close() decrements it, and the entry is removed when it reaches zero.
A hash table of length 10 uses open addressing with hash function h(k) = kmod 10 and linear probing. After inserting 6 values into an empty hash table, the table is shown below:
Slot | Key
0 |
1 |
2 | 42
3 | 23
4 | 34
5 | 52
6 | 46
7 | 33
8 |
9 |
Which of the following choices gives a possible order in which the key values could have been inserted in the table?
A46, 42, 34, 52, 23, 33
B34, 42, 23, 52, 33, 46
C46, 34, 42, 23, 52, 33
D42, 46, 33, 23, 34, 52
Show answerHide answer
Correct answer: (C) 46, 34, 42, 23, 52, 33
Explanation
Order C reproduces the table: 46→6, 34→4, 42→2, 23→3, 52→2 (taken) then 3, 4 (taken) so 5, and 33→3 then 4, 5, 6 (taken) so 7.
Which of the following MySQL query will display all the NAME from the table STUDENT, which are having maximum five characters and starting with the alphabet 'A'?
ASELECT NAME FROM STUDENT WHERE NAME LIKE 'A____';
BSELECT NAME FROM STUDENT WHERE NAME = 'A____';
CSELECT NAME FROM STUDENT WHERE NAME = 'A%%%%;
DSELECT NAME FROM STUDENT WHERE NAME LIKE 'A%%%%'
Show answerHide answer
Correct answer: (A) SELECT NAME FROM STUDENT WHERE NAME LIKE 'A____';
Explanation
LIKE with the wildcard _ matches exactly one character, so 'A____' matches names that start with A and have five characters. The = operator does not treat wildcards specially.
Select the correct output of the following C++ program segment assuming all necessary header files are correctly included:
void main( )
{
char *S = "MySQL";
S += 2;
cout << S <<endl;
}
ASQL
BQL
CMy
DMyS
Show answerHide answer
Correct answer: (A) SQL
Explanation
S points to "MySQL". S += 2 moves it past 'M' and 'y' to 'S', so cout prints the string from there: SQL.
The term ______ is used for the larger, more powerful computers other than supercomputers. It supports a large database, has elaborate I/O hardware, and is used in a central data processing facility.
AMinicomputer
BSupercomputer
CMainframe
DMicrocomputer
Show answerHide answer
Correct answer: (C) Mainframe
Explanation
A mainframe is a large, powerful computer below a supercomputer that supports large databases and extensive I/O, and is used in central data processing.
Match List-I with List-II and select the correct answer using the codes given below the Lists:
List-I
A. All-pairs shortest path
B. Quicksort
C. Minimum weight spanning tree
D. Connected components
List-II
1. Greedy
2. Depth-first search
3. Dynamic programming
4. Divide and conquer
Codes: A B C D
A2 4 1 3
B3 4 1 2
C3 4 2 1
D4 1 2 3
Show answerHide answer
Correct answer: (B) 3 4 1 2
Explanation
All-pairs shortest path (Floyd-Warshall) uses dynamic programming, quicksort uses divide and conquer, minimum spanning tree (Prim/Kruskal) is greedy, and connected components are found with DFS. That gives 3, 4, 1, 2.
Which of the following statements best describes the main reasons for normalizing relational database?
I. To Achieve physical data independence.
II. To remove data anomalies (insertion. update, deletion, anomalies).
III. To save space on disk.
AI, II and III
BI and II only
CI and III only
DII and III only
Show answerHide answer
Correct answer: (D) II and III only
Explanation
Normalization removes redundancy, which prevents insert, update and delete anomalies and saves storage space. It does not provide physical data independence, which comes from the three-level architecture.
Identify the error in the following HTML code:
<HTML>
<BODY>
<FORM ID = "FORM1" METHOD = POST>
<BR> SELECT YOUR FAVOURITE CHANNEL :
NETFLIX <INPUT TYPE = CHECKSELECT>
AMAZON PRIME <INPUT TYPE = CHECKSELECT>
</FORM>
</BODY>
</HTML>
(a) NAME instead of ID and CHECKBOX instead of CHECKSELECT.
(b) METHOD = GET instead of POST.
AOnly (a) is correct
BBoth (a) and (b) are correct
COnly (b) is correct
DThe code is correct and has no errors
Show answerHide answer
Correct answer: (A) Only (a) is correct
Explanation
Form controls need a NAME attribute to be submitted, and the input type for tick boxes is CHECKBOX. CHECKSELECT does not exist. METHOD = POST is valid, so only (a) is correct.
Select the correct output of the following C++ program segment assuming all necessary header files are correctly included.
void main ()
{
char *S = "Inheritance";
S +=6 ;
cout<<S<< endl;
}
Aitence
Btance
CTence
DInheri
Show answerHide answer
Correct answer: (B) tance
Explanation
S points to "Inheritance". S += 6 moves it to index 6 (I0 n1 h2 e3 r4 i5 t6), so cout prints "tance".
Consider the relation Emp-Dept with SSn as key.
Ename | SSn (key) | EAddr | Dept. No. | Dept. Name | Dept. Manager | SSn
Which of the following is (are) invalid operations (s)?
(i) Inserting an employee without name and address.
(ii) Inserting an employee with only SSn.
(iii) Inserting a department with no employee.
(iv) Inserting an employee without SSn.
A(i)
B(iv)
C(iii) and (iv)
D(ii) and (iii)
Show answerHide answer
Correct answer: (B) (iv)
Explanation
SSn is the primary key, and by entity integrity a key cannot be null. So inserting an employee without an SSn is invalid. Name and address may be null.
In the relation R = {(1,2), (2,3)}, the minimum number of ordered pairs that must be added to this set, so that the enlarged relation is reflexive, symmetric and transitive, is
A4
B5
C6
D7
Show answerHide answer
Correct answer: (D) 7
Explanation
Since 1~2 and 2~3, all of 1, 2 and 3 fall into one equivalence class. That needs all 3 × 3 = 9 ordered pairs. R already has 2, so 9 − 2 = 7 pairs must be added.
Which of the following statements is false with respect to Relational DBMS?
AA disadvantage of highly normalized tables is that queries may require too many time consuming joins.
BForeign key constraints are referential integrity constraints.
CA primary key uniquely indentifies a row in a table.
DNulls reduce space requirements in tables.
Show answerHide answer
Correct answer: (D) Nulls reduce space requirements in tables.
Explanation
Nulls do not reduce storage space, so (D) is false. The other statements are true: heavy normalization means more joins, foreign keys enforce referential integrity, and a primary key uniquely identifies a row.
What result set is returned from the following SQL query ?
Select customer_name, telephone
From customers
Where city in ('Jaipur','Delhi','Agra');
AThe customer_name of all customers who are not living in Jaipur, Delhi or Agra.
BThe customer_name and telephone of all customers.
CThe customer_name and telephone of all customers living in either Jaipur, Delhi or Agra.
DThe customer_name and telephone of all customers living in Jaipur, Delhi and Agra.
Show answerHide answer
Correct answer: (C) The customer_name and telephone of all customers living in either Jaipur, Delhi or Agra.
Explanation
IN matches any value in the list, so the query returns customer_name and telephone of customers whose city is Jaipur, Delhi or Agra. A customer cannot live in all three cities at once.
Refer to the monostable multivibrator circuit in the figure below. The trigger terminal (pin 2 of the IC ) is driven by a symmetrical pulsed waveform of 10 kHz. Determine the duty cycle of the output waveform.
Circuit: a 555 timer IC; pins 4 and 8 are connected to Vcc; a 10 K resistor is connected from Vcc to pins 6 and 7 (joined together); a 0.01 capacitor is connected from pins 6,7 to ground; pin 5 is connected to ground through a 0.01 capacitor; pin 1 is grounded; the Trigger Input is applied to pin 2; the Output is taken from pin 3.
In a Schmitt trigger inverter circuit, the two trip points are observed to occur at 1.8 and 2.8 V. At what input voltage levels will this device make (a) HIGH-to-LOW transition and (b) LOW-to-HIGH transition?
A2.8 V & 1.8 V
B3 V & 2 V
C4 V & 2.2 V
D2.6 V & 1.5 V
Show answerHide answer
Correct answer: (A) 2.8 V & 1.8 V
Explanation
In a Schmitt trigger inverter, the output goes HIGH to LOW when a rising input crosses the upper trip point, 2.8 V. It goes LOW to HIGH when a falling input crosses the lower trip point, 1.8 V.
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) both are true
B(A) is true, (B) is false
C(A) is false, (B) is true
D(A) and (B) both are false
Show answerHide answer
Correct answer: (D) (A) and (B) both are false
Explanation
Corrected: the book's key says (b). HAVING can be used without GROUP BY (the whole result is one group), and WHERE is applied before HAVING, so both statements are false.
Given an instance of the relation R(ABCD).
A | B | C | D
a₁ | b₁ | c₁ | d₁
a₁ | b₂ | c₂ | d₂
a₂ | b₂ | c₂ | d₃
a₃ | b₃ | c₄ | d₃
Which of the following functional dependencies hold?
A{A B} → D and D → A
B{A B → C} and B → D
C{A B} → C and B → C
D{A B} → D and A → D
Show answerHide answer
Correct answer: (C) {A B} → C and B → C
Explanation
AB → C holds because every (A, B) pair is unique, and B → C holds because b1→c1, b2→c2 (twice) and b3→c4. B → D fails (b2 gives d2 and d3), as do D → A and A → D.
This question is based on following table :
TABLE : DELIVERY
SNO | DBOY | ITEM | STAR | AMOUNT
1001 | AMAN | FOOD | 5 | 3000
1005 | JONES | MEDICINE | 3 | 5000
1008 | AMAN | MEDICINE | 2 | 4000
1009 | RAZID | FOOD | 4 | 4500
1010 | JONES | GIFT | 5 | 5000
1018 | AMAN | FOOD | 5 | 3000
1022 | RAZID | MEDICINE | 4 | 5000
Which of the following SQL commands will remove the rows, which have column value of STAR less than 5 ?
AREMOVE FROM DELIVERY WHERE STAR < 5;
BDROP TABLE DELIVERY WHERE STAR < 5;
CDELETE FROM DELIVERY WHERE STAR < 5;
DDELETE * FROM DELIVERY WHERE STAR < 5;
Show answerHide answer
Correct answer: (C) DELETE FROM DELIVERY WHERE STAR < 5;
Explanation
DELETE FROM table WHERE condition removes matching rows. There is no REMOVE command, DROP removes the whole table, and DELETE * is not valid standard SQL.
Consider the following tables in a database SPORTS :
Table 1 : STUDENTS
ADMNO | SNAME
101 | AMAR
205 | MARIA
410 | MALALA
Table 2 : GAMES
GAMEID | GNAME
G03 | CRICKET
G05 | FOOTBALL
Which of the following SQL Command will produce an output as :
SNAME | GNAME
AMAR | CRICKET
MARIA | CRICKET
MALALA | CRICKET
AMAR | FOOTBALL
MARIA | FOOTBALL
MALALA | FOOTBALL
ASELECT SNAME, GNAME FROM STUDENTS, GAMES;
BSELECT SNAME, GNAME FROM STUDENTS X GAMES;
CSELECT SNAME FROM STUDENTS, GNAME FROM GAMES;
DSELECT SNAME FROM STUDENTS, SELECT GNAME FROM GAMES;
Show answerHide answer
Correct answer: (A) SELECT SNAME, GNAME FROM STUDENTS, GAMES;
Explanation
Listing two tables with no join condition gives their Cartesian product: every student paired with every game (3 × 2 = 6 rows), which matches the output.
Determine the function performed by the combinational circuit of the given figure.
Circuit: three 2-to-1 MUXes. MUX-1 has inputs I3 (to its I1) and I2 (to its I0). MUX-2 has inputs I1 (to its I1) and I0 (to its I0). The select lines of MUX-1 and MUX-2 are tied together to S1. The output Y of MUX-1 goes to input I1 of MUX-3 and the output Y of MUX-2 goes to input I0 of MUX-3. MUX-3 has select S0 and output F.
A4-to-1 multiplexer
B8-to-1 multiplexer
C16-to-1 multiplexer
D32-to1 multiplexer
Show answerHide answer
Correct answer: (A) 4-to-1 multiplexer
Explanation
MUX-1 and MUX-2 choose between I3/I2 and I1/I0 using S1, and MUX-3 chooses between their outputs using S0. Four inputs and two select lines make a 4-to-1 multiplexer.
A hash function defined as f(key) = key mod 7 with linear probing is used to insert the keys 37, 38, 72, 48, 98, 11, 56 into a table indexed from 0 to 6. What will be the location of 11?
A3
B4
C5
D6
Show answerHide answer
Correct answer: (C) 5
Explanation
37→2, 38→3, 72→2 (taken, goes to 3, then 4), 48→6, 98→0. 11 mod 7 = 4 is taken, so linear probing places 11 at slot 5.
How to use these DSSSB TGT / PGT Computer Science questions
Every question here was asked in a real DSSSB TGT / PGT paper; the paper and shift are shown on the card, and the number opens the question on its own page. Try each one before tapping Show answer, then attempt the full DSSSB TGT / PGT papers as timed tests to check your speed under exam conditions.