WorksheetsDatabase Concepts Quiz
Total questions: 35
Worksheet time: 18mins
Which of the following best describes MongoDB?
Relational database
Document-oriented NoSQL database
Graph database
Key-value store
In MongoDB, data is stored in:
Tables
Collections
Rows
Views
The default _id field in MongoDB is of type:
Integer
String
ObjectId
UUID
Which MongoDB command is used to display all databases?
show collections
db.getCollectionNames()
show dbs
db.showDatabases()
Which method is used to insert multiple documents at once?
insert()
insertOne()
insertMany()
bulkInsert()
Which query selects all documents where age is greater than 25?
{age: > 25}
{age: {$gt: 25}}
{age: {gt: 25}}
{age: => 25}
The $and operator in MongoDB is used to:
Combine two queries where both must be true
Combine two queries where one must be true
Sort data in ascending order
Perform aggregation
Which command removes all documents from a collection but keeps the collection?
db.collection.drop()
db.collection.deleteMany({})
db.collection.removeAll()
db.collection.truncate()
Which index type supports geospatial queries?
Text index
2dsphere index
Compound index
Hashed index
In MongoDB, the $set operator is used to:
Replace an entire document
Update specific fields in a document
Delete a field
Rename a collection
Which aggregation stage groups documents by a specified field?
$match
$group
$project
$sort
To skip the first 5 documents in a query result, you use:
.limit(5)
.skip(5)
.offset(5)
.start(5)
The command to update multiple documents is:
updateOne()
updateMany()
updateAll()
bulkUpdate()
What is the maximum size of a single BSON document in MongoDB?
1 MB
16 MB
32 MB
64 MB
MongoDB stores data in which format internally?
JSON
BSON
XML
CSV
Which of the following is NOT a valid MongoDB data type?
String
Double
Timestamp
Pointer
Which command is used to rename a collection?
db.renameCollection()
db.collection.rename()
db.collection.renameCollection()
db.collection.renameTo()
What does the $in operator do?
Checks if a field exists
Matches values in an array of possible values
Checks if a field contains null
Matches only numeric values
PostgreSQL is an example of:
NoSQL database
Relational database
Graph database
Document database
Which command lists all databases in PostgreSQL?
SHOW DATABASES;
\l
LIST DATABASES;
DISPLAY DATABASES;
Which command connects to a specific database?
\connect dbname
USE dbname
CONNECT dbname;
\c dbname
Which data type is used to store true/false values?
BIT
BOOLEAN
LOGICAL
BOOL
The SERIAL keyword in PostgreSQL is used for:
String concatenation
Auto-increment integer values
Setting default values
Creating foreign keys
Which clause filters rows before aggregation?
WHERE
HAVING
FILTER
GROUP BY
Which clause filters rows after aggregation?
WHERE
HAVING
FILTER
GROUP BY
Which join returns all rows from both tables, with NULL where no match exists?
INNER JOIN
LEFT JOIN
FULL JOIN
CROSS JOIN
What does the DISTINCT keyword do?
Sorts the data
Removes duplicate rows
Counts rows
Filters null values
Which function returns the number of rows?
COUNT()
SUM()
TOTAL()
SIZE()
Which operator is used for pattern matching in PostgreSQL?
LIKE
MATCHES
PATTERN
CONTAINS
Which symbol is used as a wildcard for multiple characters in LIKE?
%
_
*
?
To change the structure of a table, you use:
MODIFY TABLE
ALTER TABLE
UPDATE TABLE
CHANGE TABLE
What is the default port number for PostgreSQL?
1433
3306
5432
1521
Which keyword is used to delete all rows from a table but keep its structure?
DELETE
TRUNCATE
DROP
REMOVE
Which PostgreSQL constraint ensures that a column cannot have NULL values?
NOT NULL
UNIQUE
PRIMARY KEY
FOREIGN KEY
Which clause combines the result of two SELECT statements, removing duplicates?
UNION
UNION ALL
INTERSECT
EXCEPT
