wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Quiz 1

Total questions: 75

Worksheet time: 56mins

Name
Class
Date
1.

How do you express the time 1:23 PM and 45 seconds in standard SQL:

a)

'1PM:23:45'

b)

time '13:23:45'

c)

'13:23.45'

d)

'1PM:23.45'

2.

Consider the table T(A: int, B: int). How do you declare T in SQL?

a)

create table T (A int, B int, primary key (A), primary key (B))

b)

create table T (A int, B int, primary key (A, B))

c)

create table T (A int primary key, B int primary key)

d)

create table T (A int, B int, primary key)

3.

Consider the tables T(A: int, B: int) et S(#A: int, #B: int, C: int). How do you declare S in SQL?

a)

create table S (A int, B int, C int, foreign key (A, B) references T(A, B))

b)

create table S (A int, B int, C int, references T(A, B))

c)

create table S (A int references T(A), B int references T(B), C int)

d)

create table S (A int foreign key, B int foreign key, C int)

4.

Consider the table T declared as follows: create table T (A varchar(20), B real). Which of the following statements insert the tuple A="Hello", B=1.0 into T?

a)

insert values ('Hello', 1.0) into T

b)

insert into T values ('Hello', 1.0)

c)

insert T ('Hello', 1.0)

d)

insert into T (A, B) values ('Hello', 1.0)

5.

Consider the table T(A: int, B: int). Which of the following statements set attribute A to 3 and attribute B to 0 for all the tuples with A equal to 2?

a)

update T set A = 3, B = 0 where A = 2

b)

update T set A = A + 1, B = 0 where A = 2

c)

update T set A + 1, 0 where A = 2

d)

update T set A = A + 1, set B = 0 where A = 2

6.

How is the date 30 September 2045 expressed in standard SQL?

a)

'09-30-2045'

b)

date '2045-09-30'

c)

date '30-09-2045'

d)

'2045-30-09'

7.

Which of the following SQL statements would delete table T?

a)

drop table T

b)

truncate table T

c)

delete from T

d)

delete from T where true

8.

Which of the following statements are true about the NULL value?

a)

NULL et 'NULL' sont equivalents

b)

NULL et null sont équivalents

c)

NULL signifie valeur inconnue ou valeur non applicable

d)

NULL ne s'applique qu'aux types numériques

9.

Which of the following pairs of words are synonymous?

a)

attribut et ligne (row)

b)

colonne (column) et tuple

c)

table et relation

d)

ligne (row) et tuple

10.

In the declaration of a trigger, which of the following keyword can precede the definition of the triggering event?

a)

during

b)

before

c)

after

d)

when

11.

Consider the tables T(#A) and S(A). Which SQL statement can violate the foreign key constraint?

a)

an insert into S

b)

an update of T

c)

a delete from S

d)

a delete from T

12.

Consider the table T(A, B) declared as follows:

create table T (A int check(A between 0 and 10), B int);

Which statement triggers the check?

a)

update T set B = 1 where A = 3;

b)

delete from T where A = 1;

c)

select distinct A from T;

d)

insert into T values (null, null);

13.

Consider the table T declared as follows:

   create table T (A int primary key, B int unique);

with the following population:

  Which statement completes successfully?

a)

insert into T values (5, null);

b)

insert into T values (3, 0);

c)

update T set B = 0 where A = 2;

d)

delete from T where A = 1 or B is null;

14.

Consider the tables T and S declared as follows:

   create table T (A int primary key);

   create table S(B int references T(A) on update cascade on delete set null):

Which of the following statements regarding cascade mode are correct?

a)

an update of T can result in an update of S

b)

an update of S can result in an update of T

c)

a delete from S can result in an update of T

d)

a delete from T can result in a delete from S

15.

Which of the following statements are true regarding the comparison between primary key and unique key?

a)

there can be several unique keys in a table, but there can only be one primary key

b)

a unique key attribute can be null, a primary key attribute cannot

c)

there can be several primary keys in a table, but there can only be one unique key

d)

a primary key attribute can be null, a unique key attribute cannot

16.

A trigger is also called an ECA rule. In this acronym :

a)

A stands for Action

b)

A stands for Atomic

c)

C stands for Concurrent

d)

E stands for Extended

17.

Which of the following mechanisms in a relational DBMS are part of the constraints family?

a)

triggers

b)

foreign keys

c)

tuple-based

d)

assertions

18.

Let a tuple-based constraint be defined on a table T. Which SQL statements passed on table T trigger the constraint check?

a)

insert

b)

select

c)

delete

d)

update

19.

In JDBC, the method Class.forName(...) is used to define:

a)

the login to use for the connection

b)

the URL of the database to connect to

c)

the password to use for the connection

d)

the name of the JDBC driver to use

20.

The method executeUpdate is used to execute the following SQL statements:

a)

select

b)

update

c)

insert

d)

delete

21.

PreparedStatement's can be used to execute the following SQL statements:

a)

update

b)

insert

c)

delete

d)

select

22.

The prototype of the methods createStatement and prepareStatement is:

a)

PreparedStatement prepareStatement()

b)

Statement createStatement(String)

c)

PreparedStatement prepareStatement(String)

d)

Statement createStatement()

23.

The interface ResultSet defines the following methods:

a)

next

b)

setString

c)

getString

d)

getFloat

24.

JDBC means:

a)

Java Database Connectivity

b)

Java Data Connection

c)

Java Database Components

d)

Java Base Connection

25.

Comparison between Statement and PreparedStatement :

a)

a PreparedStatement runs more efficiently than a Statement

b)

Statement and PreparedStatement can execute the same SQL statements

c)

a Statement can execute any SQL command whereas a PreparedStatement is limited to the select

d)

a PreparedStatement prevents SQL injection attacks

26.

The executeQuery method of the JDBC library :

a)

returns an object of type ResultSet

b)

is defined in the PreparedStatement interface

c)

is defined in the Statement interface

d)

returns an int

27.

The prototype of the setString method of the PreparedStatement interface is :

a)

void setString(int, String)

b)

void setString(String)

c)

void setString(int)

d)

void setString()

28.

A transaction...:

a)

may contain a single SQL statement

b)

must contain only one SQL statement

c)

may contain several SQL statements

d)

must contain several SQL statements

29.

What is the correct order of isolation levels:

a)

Atomicity < Durability

b)

Read Committed < Repeatable Read

c)

Serializability < Read Uncommitted

d)

Consistency < Repeatable Read

30.

A transaction ends when...:

a)

the commit statement is issued

b)

the rollback statement is issued

c)

a failure (e.g. division by 0) occurs

d)

a constraint is violated

31.

In the ACID acronym:

a)

A stands for Anomaly

b)

I stands for Isolated

c)

C stands for Constraint

d)

D stands for Data

32.

Transactions have the following properties:

a)

Durability

b)

Compatibility

c)

Integrity

d)

Efficiency

33.

Which of the following statements are correct

a)

'Phantom Reads' occurs if the transaction is running with a 'Serilizable' isolation level

b)

'Dirty Read' occurs if the transaction is running with an 'Uncommitted read' isolation level

c)

'Phantom Reads' occurs if the transaction 'runs with a Repeatable Read isolation level

d)

'Dirty Read' occurs if the transaction is executed with a 'Committed read' isolation level

34.

About insolation levels :

a)

The SERIALIZABLE insulation level is the highest

b)

A transaction that updates the database can safely use the READ UNCOMMITTED isolation level

c)

SQL defines three standard isolation levels

d)

Le niveau d'isolation SERIALIZABLE accroît le parallélisme des transactions

35.

The current transaction is validated (commits):

a)

when a new transaction is started

b)

when the rollback order is executed

c)

as soon as the first SQL command of the transaction is successfully executed

d)

if the program running the transaction abruptly terminates in the middle of the transaction

36.

Transactions have the following properties:

a)

isolation

b)

atomicity

c)

durability

d)

consistency

37.

Which one is used as the primary key in MongoDB?

a)

id

b)

_uid

c)

_uuid

d)

_id

38.

What are the fundamental properties to characterise databases?

a)

Partition Tolerance

b)

Availability

c)

Consistency

d)

Atomicity

39.

_________ is a binary serialization format used to store documents in MongoDB.

a)

Sql

b)

BSON

c)

GridFS

d)

JSON

40.

MongoDB is a database _________ that offers high performance.

a)

Key/value

b)

Oriented document

c)

Oriented graph

d)

Oriented column

41.

About JSON. Which statement below is true?

a)

A category of documents generated by a word processor

b)

Json inherits the syntax for creating objects in JavaScript

c)

JSON is a data representation format

d)

An object-oriented programming language

42.

___________ data models allow applications to store related pieces of information in the same database record.

a)

None of the mentioned

b)

Reference

c)

External

d)

Embedded

43.

A collection in MongoDB is  group of ............

a)

Schema

b)

Databases

c)

Related documents

d)

Rows

44.

Normalized data models describe relationships using ___________ between documents.

a)

evaluation

b)

relativeness

c)

none of the mentioned

d)

references

45.

Which of the following is not a NoSQL database?

a)

SQL Server

b)

Cassandra

c)

MongoDB

d)

Redis

46.

A collection and a document in MongoDB is equivalent to....................... concepts respectively. 

a)

Column and Row

b)

Table and Column

c)

Table and Row

d)

Database and Table

47.

Which MongoDB filters below are equivalent to the following SQL clause:

WHERE att BETWEEN val1 AND val2

a)

{att: { $lte: val2, $gte: val1} }

b)

{ att: { $gte: val1, $lte:val2 } }

c)

{ att: { $gt: val1, $lt:val2} } 

d)

{ att: [ val1, val2 ] }

48.

Which of the following methods matches the Order by clause in MongoDB?

a)

sort()

b)

orderBy()

c)

Order()

d)

sortBy()

49.

Which of the following filters translates "the field" foo "is different from 10": (foo!=10)

a)

{ foo: { $ne: 10 } }

b)

{ foo: !10 }

c)

{ foo: {$not: { $eq: 10 } } }

d)

{ $not: {foo: 10 } }

50.

Which documents below match the filter { tab: { $gt: 3, $lt: 0 } :

a)

{ tab: [ 5, -1 ] }

b)

{ tab: [ 5, 0 ] }

c)

{ tab: [ 0,3 ] }

d)

{ tab: [ 0, -1 ] }

51.

How to specify "and" between these two conditions {f1: v1} and {f2: v2}:

a)

{$and: {f1: v1}, {f2: v2}}

b)

{{f1: v1} $and {2: v2}}

c)

{$and: {f1: v1, f2: v2}}

d)

{$and: [{f1: v1}, {f2: v2}]}

52.

"foo" is a field with an array value. Which filter retrieves the documents with a foo array of size 3:

a)

{foo: {$size: 3}}

b)

{foo: 3}

c)

{$size: {foo: 3}}

d)

{foo, $size, 3}

53.

Which of the documents below matches the filter { foo: "a?.*z$" } :

a)

{ foo: "a?.*z$" }

b)

{ foo: "z" }

c)

{ foo: "a?z" }

d)

{ foo: "aaz" }

54.

Which of the following  query will show posts collection in sorted format with author key ascending?

a)

db.posts.find().sort('author':1)

b)

None of the mentioned

c)

db.posts.find().sort({'author':1})

d)

db.posts.findOne().sort({'author':0})

55.

A query may include a ___________ that specifies the fields from the matching documents to return.

a)

union

b)

Projection

c)

None of the mentioned

d)

Selection

56.

Which of the following operators can be used in an aggregate() pipeline?

a)

$project

b)

$group

c)

$match

d)

$unwind

57.

Which of the following aggregate pipelines ouput the same result as the SQL query below.

select A, count(*)

from R

where A >= 0

group by A

Note: We only consider the produced VALUES; we do NOT consider colum names or field names.

a)

[ { $match: { A: { $gte: 0 } } }, { $group: { _id: "A", { $sum: 1 } } } ]

b)

[ { $match: { A: { $gte: 0 } } }, { $group: { _id: "$A", { $sum: 1 } } } ]

c)

[ { $group: { _id: "$A", { $sum: 1 } } }, { $match: { A: { $gte: 0 } } } ]

d)

[ { $match: { A: { $gte: 0 } } }, { $group: { _id: "$A", { $sum: "$A" } } } ]

58.

Which SQL query is equivalent to:

db.mycollection.aggregate( [ 

   { $group: { _id: "$att2",  foo: { $min: "$att3"} } } ,

   { $match: { _id: val2 } }

] ) 

a)

SELECT MIN(att3) AS foo

FROM mycollection

WHERE att2 = val2

GROUP BY att2

b)

SELECT MIN(att3) AS foo

FROM mycollection

GROUP BY att2

WHERE att2 = val2

c)

SELECT MIN(att3) AS foo

FROM mycollection

GROUP BY att2

HAVING att2 = val2

d)

SELECT MIN(att3) AS foo

FROM mycollection

WHERE att2 = val2

59.

When specifying a multi-stage aggregate() pipeline...

a)

the output of stage N is the input of stage N+1

b)

the input of the last stage is the final result returned by the aggregate() method

c)

the input of stage N is the output of stage N-1 

d)

the input of stage N is the output of stage N+1 

60.

Which of the following $group stage specification is valid:

a)

{ $group: {_id: "$foo", _id: "$bar", maxFoo: { $max: "$foo" } } }

b)

{ $group: { maxFoo: { $max: "$foo" } } }

c)

{ $group: { _id: "$foo" } }

d)

{ $group: { _id: null, maxFoo: { $max: "$foo" } } }

61.

Which of the following operators can be used in an aggregate() pipeline?

c)

$unionWith

d)

$lookup

62.

In an aggregate() pipeline...

a)

there may be no $match floor

b)

there must be exactly one floor $match

c)

there can be several stages $match

d)

there must be at least one $match floor

63.

what is the relational equivalent of:

db.macollection.aggregate( [ 

   { $match: { att1: val1 } }, 

   { $group: { _id: "$att2",  truc: { $min: "$att3"} } } 

] ) 

a)

SELECT MIN(att3) AS truc

FROM macollection

WHERE att1 = val1 

GROUP BY att2

b)

SELECT MIN(att3) AS truc

FROM macollection

GROUP BY att2

HAVING att1 = val1

c)

SELECT MIN(att3) AS truc

FROM macollection

GROUP BY att2

d)

SELECT MIN(att3) AS truc

FROM macollection

WHERE att1 = val1

64.

what is the relational equivalent of:

db.orders.aggregate( [ { $match: { status: 'A' } }, { $group: { id: "$custid", total: { $sum: "$price" } } }, { $match: { total: { $gt: 250 } } } ] )

a)

SELECT cust_id, SUM(price) as total FROM orders WHERE status = 'A' GROUP BY cust_id HAVING total > 250

b)

SELECT cust_id, SUM(price) as total FROM orders WHERE status = 'A' GROUP BY cust_id HAVING total >= 250

c)

SELECT cust_id, SUM(price) as total FROM orders GROUP BY cust_id HAVING total >= 250 , status='A'

d)

SELECT cust_id, COUNT(price) as total FROM orders WHERE status = 'A' GROUP BY cust_id HAVING total > 250

65.

what is the relational equivalent of:

db.orders.aggregate( [

   {

     $group: {

        _id: null,

        count: { $sum: 1 } }  }] )

a)

SELECT SUM(1) AS count

FROM orders

b)

SELECT COUNT(1) AS count

FROM orders

c)

SELECT SUM(*) AS count

FROM orders

d)

SELECT COUNT(*) AS count

FROM orders

66.

The updateOne() method:

a)

can update a document

b)

returns as sole information a boolean indicating whether an update has taken place

c)

returns "matchedCount = true", if an update has taken place

d)

peut mettre à jour plusieurs documents

67.

The UpdateMany() method:

a)

By default upsert = true

b)

By default ordered = true

c)

By default upsert = false

d)

By default ordered = false

68.

The insertOne() method:

a)

returns among other information the number of correctly inserted documents

b)

allows you to insert several documents

c)

allows the insertion of documents with duplicate Id

d)

retourne un seul document

69.

The operators for specifying an update via updateOne() are :

a)

$unset

b)

$get

c)

$size

d)

$set

70.

The deleteOne() method:

a)

returns an error if the specified filter does not match any document

b)

allows you to delete a single document

c)

returns a document

d)

can be used to delete all documents in a collection

71.

The return type of the updateOne() method:

a)

a document that contains a field named "modifiedCount" (among other fields)

b)

an integer

c)

a boolean

d)

a document that contains a field named "matchedCount" (among other fields)

72.

The insertMany() method:

a)

returns a document

b)

takes two parameters, each of which is mandatory

c)

can be used to insert only one document

d)

returns, among other things, the _id value of the inserted documents

73.

The return value of the deleteOne() method is:

a)

an integer, representing the number of deleted documents

b)

a boolean, specifying whether the delete succeeded or not

c)

a document that contains the number of deleted documents (among other informations)

d)

Only the Id of deleted document

74.

Consider a collection that only contains the following document: { _id: 10, bar: "abc" }. Which of the following new insetion on that collection will succeed?

a)

insertOne( { _id: 20, bar: "abc" } )

b)

insertOne( { bar: "abc" } )

c)

insertOne( { _id: 10, bar: "abc" } )

d)

insertOne( { } )

75.

The return type of the deleteMany() method:

a)

a boolean

b)

an integer

c)

a document

d)

an array of documents