Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.

Unit 6 MCQs Getting started with databases

INT221 — Mvc Programming 50 questions. Pick an option to check it.

Read the notes Subjective questions

0 of 50 answered 0 right 0 wrong , 50 left

  1. Question 1 of 50

    Which Artisan command is used to generate a new Eloquent model in Laravel?

  2. Question 2 of 50

    By default, what table name will Laravel assume for a model named Flight?

  3. Question 3 of 50

    If your database table does not follow the default naming convention, which property must be defined in the Model to specify the table name?

  4. Question 4 of 50

    What is the primary purpose of Database Migrations in an MVC framework like Laravel?

  5. Question 5 of 50

    Which method in a migration file is used to reverse the operations performed by the up method?

  6. Question 6 of 50

    Which Artisan command executes all outstanding migrations?

  7. Question 7 of 50

    In the context of the Query Builder, which method is used to retrieve all rows from a table?

  8. Question 8 of 50

    When using Query Builder, how do you prevent SQL injection when adding a WHERE clause?

  9. Question 9 of 50

    What is the result of the following Query Builder code?

    $user = DB::table('users')->where('name', 'John')->first();

  10. Question 10 of 50

    Which property in an Eloquent model allows you to specify which attributes are mass assignable?

  11. Question 11 of 50

    Conversely, which property acts as a blacklist for mass assignment in Eloquent?

  12. Question 12 of 50

    Which of the following describes the syntax to create a new record using Eloquent Mass Assignment?

  13. Question 13 of 50

    What is the purpose of Database Seeding?

  14. Question 14 of 50

    Which Artisan command creates a new Seeder class?

  15. Question 15 of 50

    When using Laravel with MongoDB, which library is commonly used to provide Eloquent-like functionality?

  16. Question 16 of 50

    In a MongoDB Eloquent model, what class should the Model extend instead of Illuminate\Database\Eloquent\Model?

  17. Question 17 of 50

    What is the default primary key field name in MongoDB?

  18. Question 18 of 50

    How do you handle migrations for MongoDB in Laravel given it is schema-less?

  19. Question 19 of 50

    Which Eloquent method is used to retrieve a model by its primary key or throw an exception if not found?

  20. Question 20 of 50

    In a REST API implemented with Laravel, which HTTP method corresponds to the update action?

  21. Question 21 of 50

    When building an API, what is the standard HTTP status code for a successful resource creation?

  22. Question 22 of 50

    To transform Eloquent models into a specific JSON format for an API, what Laravel feature is recommended?

  23. Question 23 of 50

    Which file is specifically designated for defining API routes in a standard Laravel installation?

  24. Question 24 of 50

    In Eloquent, how do you define a Soft Delete?

  25. Question 25 of 50

    What is the equivalent of an SQL JOIN in Eloquent ORM?

  26. Question 26 of 50

    Which command would you use to rollback the very last migration operation?

  27. Question 27 of 50

    When using the Query Builder, which method creates a raw expression that is injected into the query as-is?

  28. Question 28 of 50

    In an API Controller, what method is conventionally used to show a single specific resource?

  29. Question 29 of 50

    Which of the following is correct to delete a user with ID 1 using Eloquent?

  30. Question 30 of 50

    If you are using MongoDB with Laravel, which operator is often used within where clauses for complex comparisons?

  31. Question 31 of 50

    What does the timestamps() method create in a migration file?

  32. Question 32 of 50

    In Eloquent, what is the default format for the $timestamps properties?

  33. Question 33 of 50

    Which method enables you to call a seeder from within another seeder (e.g., inside DatabaseSeeder)?

  34. Question 34 of 50

    When defining a foreign key in a migration, what does constrained() do in modern Laravel syntax?
    Example: $table->foreignId('user_id')->constrained();

  35. Question 35 of 50

    Which return response is most appropriate for an API endpoint if a requested resource is not found?

  36. Question 36 of 50

    What function is used to convert an Eloquent collection to a JSON string directly?

  37. Question 37 of 50

    Consider the equation for pagination offset: . Which Query Builder method handles this calculation automatically?

  38. Question 38 of 50

    In a MongoDB Laravel model, how are embedded documents usually accessed?

  39. Question 39 of 50

    What is the purpose of Model Factories in the context of Seeding?

  40. Question 40 of 50

    Which query builder method is used to update an existing record?

  41. Question 41 of 50

    To use a specific database connection for a model other than the default, which property is used?

  42. Question 42 of 50

    In a REST API, what does the HEAD method do?

  43. Question 43 of 50

    When defining an Eloquent relationship, return $this->hasMany(Comment::class); implies what relationship structure?

  44. Question 44 of 50

    If you want to run a raw SQL query using the facade but do not need a return value (e.g., deleting), which method is used?

  45. Question 45 of 50

    Which Artisan command generates a migration file specifically to modify an existing table?

  46. Question 46 of 50

    How do you define a route parameter in Laravel (often used for REST APIs)?

  47. Question 47 of 50

    In Eloquent, what is the 'N+1 query problem'?

  48. Question 48 of 50

    How is the N+1 query problem solved in Eloquent?

  49. Question 49 of 50

    When using MongoDB with Laravel, if you want to store a date, it is stored as:

  50. Question 50 of 50

    Which interface must a resource class implement to define how a model maps to JSON?

That's unit 6

Answer a few questions and your score shows up here.