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.
Data frame in Pandas has a method which takes a column name (for a regular index) or
a list of column names to create a new, re-indexed data frame, which of the following
is correct method?
AdFb
Bdata.index ( )
Cset_index ( )
DdFmi
Show answerHide answer
Correct answer: (C) set_index ( )
Explanation
set_index() takes a column name or list of column names and returns a new DataFrame indexed by those columns.
Which of the following maths function in SQL returns the smallest integer greater than,
or equal to, the specified numeric expression?
AROUND
BCEILING
CABS
DFLOOR
Show answerHide answer
Correct answer: (B) CEILING
Explanation
CEILING returns the smallest integer greater than or equal to the value, e.g. CEILING(4.2) = 5. FLOOR returns the largest integer less than or equal to it.
Which of the following phase of the compiler, gathers type information and saves it in
either the syntax tree or the symbol table, for subsequent use during intermediate
code generation?
ASemantic Analyzer
BCode Analyzer
CSyntax Analyzer
DLexical Analyzer
Show answerHide answer
Correct answer: (A) Semantic Analyzer
Explanation
The semantic analyzer checks meaning and gathers type information, storing it in the syntax tree or symbol table for intermediate code generation.
In Database Management System (DBMS), which of the following term de fines a
collection of entities that have the same attributes in the database?
AEntity type
BValue set
CEntity set
DValue type
Show answerHide answer
Correct answer: (A) Entity type
Explanation
Per Elmasri-Navathe, an entity type defines a collection of entities that have the same attributes; the actual set of entities at a moment is the entity set.
Which of the following term of ER model (Entity – Relationship) is corresponding to
the foreign key (or relationship relation) in the relational model of database?
AComposite attribute
BEntity type
C1 : 1 (one to one) or 1 : N (one to many) relationship type
DM : N (many to many) relationship type
Show answerHide answer
Correct answer: (C) 1 : 1 (one to one) or 1 : N (one to many) relationship type
Explanation
In ER-to-relational mapping, a 1:1 or 1:N relationship type corresponds to a foreign key (or a relationship relation) in the relational model.
In relational databases, which of the following integrity constraint is specified between
two relations and is used to maintain the consistency among tuples in the two
relations?
Referential integrity is specified between two relations: a foreign key value must match an existing primary key in the referenced relation, keeping tuples consistent.
In SQL, which of the following is correct command for schema evolution, if the
RESTRICT option is chosen than the schema is dropped only if schema has no
element in it?
ADELET E
BUPDAT E
CALT ER
DDROP
Show answerHide answer
Correct answer: (D) DROP
Explanation
DROP SCHEMA name RESTRICT removes the schema only if it has no elements; CASCADE would drop it with all its contents.
What is the difference between a primary key and a foreign key in a database?
AA primary key is used to sort records in a table, while a foreign key is used to filter records in a table.
BA primary key is a unique identifier for each record in a table, while a foreign key is used to link records in one table to records in another table.
CThere is no difference between a primary key and a foreign key.
DA primary key is used to link records in one table to records in another table, while a foreign key is a unique identifier for each record in a table.
Show answerHide answer
Correct answer: (B) A primary key is a unique identifier for each record in a table, while a foreign key is used to link records in one table to records in another table.
Explanation
A primary key uniquely identifies each row in its table. A foreign key refers to a primary key in another table, which links the tables.
What is the difference between a join and a subque1Y in a database?
AA join is used to retrieve data from a single table based on a condition, while a subquery is used to combine data from multiple tables based on a common column.
BA join is used to sort data in a table, while a subquery is used to filter data in a table.
CA join is used to combine data from multiple tables based on a common column, while a subquery is used to retrieve data from a single table based on a condition.
DThere is no difference between a join and a subquery.
Show answerHide answer
Correct answer: (C) A join is used to combine data from multiple tables based on a common column, while a subquery is used to retrieve data from a single table based on a condition.
Explanation
A join combines rows from several tables on a related (common) column. A subquery is a query nested inside another query, often used to filter on a condition.
What is the difference between a B-tree and a Hash index in a database?
AA B-tree index is used to sort data in a table, while a Hash index is used to filter data in a table.
BA B-tree index is used for exact match queries and sorts data using a hash function, while a Hash index is used for range queries and sorts data in a hierarchical structure.
CA B-tree index is used for range queries and sorts data in a hierarchical structure, while a Hash index is used for exact match queries and sorts data using a hash function.
DThere is no difference between a B-tree and a Hash index.
Show answerHide answer
Correct answer: (C) A B-tree index is used for range queries and sorts data in a hierarchical structure, while a Hash index is used for exact match queries and sorts data using a hash function.
Explanation
B-tree indexes keep keys in sorted, hierarchical order, so they handle range queries well. Hash indexes use a hash function, which is good for exact-match lookups but not ranges.
Which one of the following is NOT a prerequisite for a good MIS?
ADatabase
BControl and maintenance of MIS
CMIS executives
DSupport from staff
Show answerHide answer
Correct answer: (D) Support from staff
Explanation
Per the key, a database, MIS executives and control and maintenance of the MIS are the core prerequisites of a good MIS, while staff support is not counted as one.
DDL commands (CREATE, ALTER, DROP) define and change the structure (schema) of relations and remove them. DML only queries and modifies the data stored in them.
An XML processor (parser) reads XML documents and gives applications access to their content and structure, for example through DOM or SAX. An XML schema only defines the valid structure.
In a relational database, data is stored in tables (relations) of rows and columns, and the tables are linked through keys. Fields and records are just parts of a table.
Which of the following DBMS scenarios will NOT really follow Armstrong's Axiom?
AReflexivity rule
BPseudo transitivity rule
CTransitivity rule
DArmstrong's axioms
Show answerHide answer
Correct answer: (B) Pseudo transitivity rule
Explanation
Armstrong's axioms are only reflexivity, augmentation and transitivity. Pseudo-transitivity is a derived rule (inferred from these axioms), not one of the axioms themselves.
fork() splits a process into concurrent parts, and join() waits for them to finish and recombine. Together they form a complete concurrent subroutine; sleep() only suspends execution.
______ are a database applications' universal front end that connects to the back end via the internet.
AWeb browsers
BWeb server
CSoftware programs
DWeb application
Show answerHide answer
Correct answer: (A) Web browsers
Explanation
Web browsers act as a universal client (front end) for web-based database applications. They send requests over the Internet to the web or application server that connects to the back-end database.
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.