wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Câu hỏi trắc nghiệm về Database, Migration và ORM

Total questions: 50

Worksheet time: 25mins

Name
Class
Date
1.

Database model dùng để làm gì trong hệ thống?

a)

Lưu trữ CSS

b)

Mô tả cấu trúc và quan hệ dữ liệu

c)

Chạy middleware

d)

Render Blade

2.

Trong mô hình quan hệ, bảng gồm những thành phần nào?

a)

Chỉ hàng

b)

Chỉ cột

c)

Hàng và cột

d)

Không có hàng và cột

3.

Thuộc tính (attribute) là gì?

a)

Mỗi hàng trong bảng

b)

Mỗi cột trong bảng

c)

Tên database

d)

Kiểu dữ liệu của bảng

4.

Trong Model Book, $fillable dùng để làm gì?

a)

Tạo bảng

b)

Cho phép ghi các trường vào DB

c)

Xóa bảng

d)

Tạo route

5.

Thuộc tính nào sau đây nằm trong $fillable của Book?

a)

created_at

b)

id

c)

bookName

d)

updated_at

6.

Để tạo migration bảng books, dùng lệnh nào?

a)

php artisan create:migration books

b)

php artisan migrate:create books

c)

php artisan make:migration create_books_table

d)

php artisan make:model books

7.

Trong migration, Schema::create() dùng để làm gì?

a)

Tạo model

b)

Tạo bảng trong database

c)

Tạo view

d)

Tạo route

8.

Lệnh nào chạy migration?

a)

php artisan make:migration

b)

php artisan db:seed

c)

php artisan migrate

d)

php artisan serve

9.

Lệnh nào tạo application key?

a)

php artisan key:add

b)

php artisan key:generate

c)

php artisan make:key

d)

php artisan gen:key

10.

Trong migration, cột bookName có kiểu dữ liệu gì theo code?

a)

text

b)

string

c)

integer

d)

boolean

11.

ORM viết tắt của điều gì?

a)

Object Route Method

b)

Object Relational Mapping

c)

Only Relational Model

d)

One Role Mapping

12.

ORM giúp bạn làm việc với database như thế nào?

a)

Bằng SQL thuần

b)

Bằng đối tượng trong code

c)

Bằng HTML

d)

Bằng CSS

13.

Lệnh chạy seeder là gì?

a)

php artisan seed

b)

php artisan db:seed

c)

php artisan serve

d)

php artisan migrate

14.

Hàm nào trong migration dùng để xóa bảng?

a)

remove

b)

clear

c)

drop

d)

dropIfExists

15.

Trong controller, Book::all() dùng để làm gì?

a)

Lấy toàn bộ dữ liệu bảng books

b)

Xóa toàn bộ dữ liệu

c)

Cập nhật toàn bộ dữ liệu

d)

Tạo toàn bộ dữ liệu

16.

Trong View Blade, cú pháp hiển thị biến là gì?

a)

{{ $var }}

b)

<< $var >>

c)

( $var )

d)

[[ $var ]]

17.

Trong Blade, vòng lặp foreach viết như thế nào?

a)

@for {}

b)

@foreach()

c)

@loop()

d)

@repeat()

18.

Hành động nào tương ứng với route GET /book?

a)

Gọi controller update

b)

Gọi controller destroy

c)

Gọi controller book()

d)

Gọi controller create

19.

Để return view và truyền dữ liệu, dùng cú pháp nào?

a)

return show('page', $data)

b)

return blade('page', $data)

c)

return make('page', compact($data))

d)

return view('page', compact('data'))

20.

Route sau có nghĩa là gì? Route::get('/book', ...)

a)

Xử lý khi người dùng gửi form

b)

Xử lý URL bằng phương thức GET

c)

Xử lý API

d)

Tạo model mới

21.

Trong Model Book, class phải kế thừa gì?

a)

Controller

b)

View

c)

Database

d)

Model

22.

Trong Migration, $table->timestamps() tạo ra gì?

a)

created_at và updated_at

b)

id

c)

revised_at

d)

Không tạo gì

23.

Để tạo model Book kèm migration, dùng lệnh nào?

a)

php artisan make:model Book

b)

php artisan make:model Book -m

c)

php artisan model Book

d)

php artisan new:model Book

24.

$book->bookName biểu diễn điều gì?

a)

Thuộc tính của controller

b)

Cột bookName trong bảng books

c)

Tên route

d)

Tên migration

25.

Hàm compact('books') trả về gì?

a)

Mảng chứa key "books"

b)

Một số nguyên

c)

Một object

d)

Một route

26.

Khi chạy seed, dữ liệu được đưa vào đâu?

a)

Vào cơ sở dữ liệu (các bảng liên quan)

b)

Vào file log

c)

Vào bộ nhớ đệm (cache)

d)

Vào session của người dùng

27.

Trong route, cú pháp gọi controller là gì?

a)

Route::go

b)

Route::controller

c)

Route::get('/book', Controller@method)

d)

Route::action

28.

Để hiển thị toàn bộ sách trong view, cần?

a)

foreach($books)

b)

foreach($book)

c)

for($books)

d)

print($books)

29.

Một entity là gì?

a)

Một bảng

b)

Một đối tượng như Sách, Sinh viên

c)

Một biến

d)

Một controller

30.

Relationship mô tả điều gì?

a)

Mối liên quan giữa các route

b)

Mối liên kết giữa thực thể dữ liệu

c)

Mối quan hệ giữa file CSS

d)

Mối quan hệ giữa controller và view

31.

Route nào đúng để gọi hàm book()?

a)

Route::put

b)

Route::get('/book', ...)

c)

Route::delete

d)

Route::view

32.

$table->string('NXB') có nghĩa là gì?

a)

Tạo cột kiểu integer

b)

Tạo cột kiểu string

c)

Tạo cột kiểu boolean

d)

Tạo cột kiểu longtext

33.

$books = Book::all(); trả về kiểu dữ liệu gì?

a)

Một mảng PHP

b)

Một Collection

c)

Một string

d)

Một số

34.

Tại sao cần php artisan key:generate?

a)

Để tạo key bảo mật của ứng dụng

b)

Để tạo database

c)

Để tạo migration

d)

Để tạo route

35.

Laravel ORM sử dụng class nào làm nền tảng?

a)

Eloquent

b)

SQL

c)

PDO

d)

API

36.

Tại sao cần chạy php artisan migrate?

a)

Để tạo route

b)

Để chạy các file migration tạo bảng

c)

Để xóa bảng

d)

Để hiển thị giao diện

37.

Giá trị trả về từ view('books', compact('books')) là gì?

a)

HTML

b)

JSON

c)

XML

d)

CSS

38.

Trong Blade, {{ $books }} sẽ hiển thị gì?

a)

Tên file

b)

Mảng/Collection của sách

c)

CSS

d)

Route hiện tại

39.

Để lấy dữ liệu chỉ một sách theo ID, dùng?

a)

Book::first()

b)

Book::find($id)

c)

Book::new()

d)

Book::route()

40.

Để lấy sách có bookName bắt đầu bằng “L”, dùng?

a)

Book::whereStart('L')

b)

Book::like('L%')

c)

Book::where('bookName','like','L%')

d)

Book::sort('L')

41.

Route nào tạo redirect?

a)

Route::goto

b)

Route::redirect('/old','/new')

c)

Route::send('/old','/new')

d)

Route::swap

42.

Trong Blade, để xuống dòng giữa dữ liệu sách, dùng gì?

a)

b)

c)

d)


43.

Khi chạy seeder, file nào chạy đầu tiên?

a)

BookSeeder

b)

DatabaseSeeder

c)

TableSeeder

d)

UserSeeder

44.

Trong Eloquent, để sắp xếp danh sách theo bookName ASC?

a)

Book::order('bookName')

b)

Book::sortBy()

c)

Book::orderBy('bookName','asc')

d)

Book::asc()

45.

Dòng return view('books', compact('books')); nằm trong phần nào?

a)

Route

b)

Controller

c)

Model

d)

Migration

46.

File migration được lưu trong thư mục nào?

a)

/app/Http

b)

/database/migrations

c)

/routes

d)

/config

47.

Để rollback migration, dùng lệnh nào?

a)

php artisan migrate:back

b)

php artisan migrate:rollback

c)

php artisan migrate:down

d)

php artisan migrate:undo

48.

Khi route gọi controller sai tên hàm, điều gì xảy ra?

a)

Tự động sửa

b)

Laravel báo lỗi

c)

Không ảnh hưởng

d)

Hiển thị dữ liệu trống

49.

Một seeder thường được dùng để làm gì?

a)

Tạo blade

b)

Tạo dữ liệu mẫu trong database

c)

Tạo route mới

d)

Tạo model

50.

Trong Eloquent, để lấy tất cả cột nhưng giới hạn 10 dòng?

a)

Book::only(10)

b)

Book::limit(10)

c)

Book::get(10)

d)

Book::take(10)->get()