NEW
Font size
WorksheetsNodejs: Database Migration and Seeders with (ORM/ODM)
Total questions: 20
Worksheet time: 10mins
What is the primary purpose of database migrations
data backup
schema version control
query optimization
data encryption
Which of these best describes a database schema?
A database schema is considered the “blueprint” of a database which describes how the data may relate to other tables or other data models.
A database schema is considered the “content” of a database which describes how the data may relate to other tables or other data models.
A database schema is considered the “code” of a database which describes how the data may relate to other tables or other data models.
none of the options
What a seeders used for?
Planting seed in the gound
Populating the database with initial data
creating database indexes
generating random data for testing
What is the full meaning of ORM?
Object Relations Map
Over Relational Mapping
Object Relational Mapping
Object Revelation Mapping
When doing migrations, what does "up" in the function stand for?
Rollback the migration
Define the structure and changes for the migration
Seed the database with initial data
Delete the migration file
Which method/function rolls back a migration?
up
down
rollback
reverse
What is an advantage of using migrations in database management?
makes it easier to hide the database schema.
improves database query performance.
provide version control for database structure.
automate data backups.
What is Mongoose primarily used for?
Relational database management
Front-end development
Object-Document Mapping (ODM) for MongoDB
SQL database management
what is the purpose of a schema?
execute database queries
create a new database
seed the database with initial data
define the database structure
What is the primary difference between migrations in Sequelize and schema migrations in Mongoose?
Sequelize migrations are for SQL databases, while Mongoose schema migrations are for MongoDB databases.
Sequelize migrations use JavaScript, while Mongoose schema migrations use TypeScript.
Sequelize migrations are for creating new databases, while Mongoose schema migrations are for seeding data.
There is no difference; they serve the same purpose.
In Mongoose, what is the purpose of the "mongoose.connect()" method?
To create a new database
To define the database schema
To establish a connection to a MongoDB server
To run migrations
In Mongoose, how can you seed initial data into a MongoDB collection?
Use the "mongoose.seed()" method
Write a custom JavaScript file to insert data
Use the "mongoose-populate" plugin
There is no built-in seeder in Mongoose
Which Mongoose method is used to update documents in a collection?
updateOne
save
modify
edit
Which Mongoose method is used to populate a field with data from another collection?
populate
link
join
merge
In Sequelize, what is the purpose of the "defaultValue" property when defining a column?
To make the column required
To create a foreign key constraint
To set a default value for the column
To define the data type of the column
Which Sequelize method is used to run all seeders?
npx sequelize-cli db:seed:all
npx sequelize-cli db:all:seed
npx sequelize-cli all:db:seed
npx sequelize-cli execute:all:seed
Which Sequelize method is used to define associations between models?
defineAssociation()
associate()
setAssociation()
linkModels()
What is the purpose of the onDelete option when defining associations in Sequelize?
It specifies the order of migration execution
It sets a default value for the associated field.
It defines the action to be taken when a referenced record is deleted.
It specifies the data type of the association.
In Mongoose, how can you ensure that a field is unique within a collection?
Create a separate schema for unique fields
Apply a custom validation function to the schema
Use the unique option when defining the schema field
Use the uniqueField() method
What is the purpose of middleware functions in Mongoose?
To create new databases
To define schema structures
To handle document pre and post operations
To perform data seeding
