wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Nodejs: Database Migration and Seeders with (ORM/ODM)

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

What is the primary purpose of database migrations

a)

data backup

b)

schema version control

c)

query optimization

d)

data encryption

2.

Which of these best describes a database schema?

a)

A database schema is considered the “blueprint” of a database which describes how the data may relate to other tables or other data models.

b)

A database schema is considered the “content” of a database which describes how the data may relate to other tables or other data models.

c)

A database schema is considered the “code” of a database which describes how the data may relate to other tables or other data models.

d)

none of the options

3.

What a seeders used for?

a)

Planting seed in the gound

b)

Populating the database with initial data

c)

creating database indexes

d)

generating random data for testing

4.

What is the full meaning of ORM?

a)

Object Relations Map

b)

Over Relational Mapping

c)

Object Relational Mapping

d)

Object Revelation Mapping

5.

When doing migrations, what does "up" in the function stand for?

a)

Rollback the migration

b)

Define the structure and changes for the migration

c)

Seed the database with initial data

d)

Delete the migration file

6.

Which method/function rolls back a migration?

a)

up

b)

down

c)

rollback

d)

reverse

7.

What is an advantage of using migrations in database management?

a)

makes it easier to hide the database schema.

b)

improves database query performance.

c)

provide version control for database structure.

d)

automate data backups.

8.

What is Mongoose primarily used for?

a)

Relational database management

b)

Front-end development

c)

Object-Document Mapping (ODM) for MongoDB

d)

SQL database management

9.

what is the purpose of a schema?

a)

execute database queries

b)

create a new database

c)

seed the database with initial data

d)

define the database structure

10.

What is the primary difference between migrations in Sequelize and schema migrations in Mongoose?

a)

Sequelize migrations are for SQL databases, while Mongoose schema migrations are for MongoDB databases.

b)

Sequelize migrations use JavaScript, while Mongoose schema migrations use TypeScript.

c)

Sequelize migrations are for creating new databases, while Mongoose schema migrations are for seeding data.

d)

There is no difference; they serve the same purpose.

11.

In Mongoose, what is the purpose of the "mongoose.connect()" method?

a)

To create a new database

b)

To define the database schema

c)

To establish a connection to a MongoDB server

d)

To run migrations

12.

In Mongoose, how can you seed initial data into a MongoDB collection?

a)

Use the "mongoose.seed()" method

b)

Write a custom JavaScript file to insert data

c)

Use the "mongoose-populate" plugin

d)

There is no built-in seeder in Mongoose

13.

Which Mongoose method is used to update documents in a collection?

a)

updateOne

b)

save

c)

modify

d)

edit

14.

Which Mongoose method is used to populate a field with data from another collection?

a)

populate

b)

link

c)

join

d)

merge

15.

In Sequelize, what is the purpose of the "defaultValue" property when defining a column?

a)

To make the column required

b)

To create a foreign key constraint

c)

To set a default value for the column

d)

To define the data type of the column

16.

Which Sequelize method is used to run all seeders?

a)

npx sequelize-cli db:seed:all

b)

npx sequelize-cli db:all:seed

c)

npx sequelize-cli all:db:seed

d)

npx sequelize-cli execute:all:seed

17.

Which Sequelize method is used to define associations between models?

a)

defineAssociation()

b)

associate()

c)

setAssociation()

d)

linkModels()

18.

What is the purpose of the onDelete option when defining associations in Sequelize?

a)

It specifies the order of migration execution

b)

It sets a default value for the associated field.

c)

It defines the action to be taken when a referenced record is deleted.

d)

It specifies the data type of the association.

19.

In Mongoose, how can you ensure that a field is unique within a collection?

a)

Create a separate schema for unique fields

b)

Apply a custom validation function to the schema

c)

Use the unique option when defining the schema field

d)

Use the uniqueField() method

20.

What is the purpose of middleware functions in Mongoose?

a)

To create new databases

b)

To define schema structures

c)

To handle document pre and post operations

d)

To perform data seeding