Recall & Review
beginner
What is the default naming convention for database tables in Laravel?
Laravel uses plural snake_case names for tables by default. For example, a model named
User corresponds to a table named users.Click to reveal answer
beginner
Why does Laravel use plural table names by default?
Plural table names represent collections of records, like a list of users or posts. This matches how we think about tables storing many items.
Click to reveal answer
intermediate
How should you name pivot tables in Laravel for many-to-many relationships?
Pivot tables should be named by combining the two related table names in alphabetical order, separated by an underscore. For example,
role_user for roles and users.Click to reveal answer
beginner
What naming style does Laravel use for table names?
Laravel uses snake_case for table names, which means all lowercase letters with underscores between words, like
blog_posts.Click to reveal answer
intermediate
Can you customize the table name in a Laravel model?
Yes, you can set a custom table name by defining the
protected $table property inside your model class.Click to reveal answer
What is the default table name for a Laravel model named
ProductCategory?✗ Incorrect
Laravel converts model names to plural snake_case table names, so
ProductCategory becomes product_categories.How should a pivot table be named for models
User and Role?✗ Incorrect
Pivot tables are named by combining related table names in alphabetical order with an underscore:
role_user.Which naming style does Laravel use for table names?
✗ Incorrect
Laravel uses snake_case for table names, meaning lowercase letters with underscores.
How can you specify a custom table name in a Laravel model?
✗ Incorrect
You define
protected $table inside the model to customize the table name.Why is it important to follow Laravel's table naming conventions?
✗ Incorrect
Following conventions lets Laravel automatically find tables without extra configuration.
Explain Laravel's default table naming conventions and why they are useful.
Think about how Laravel matches models to tables without extra setup.
You got /4 concepts.
Describe how to name pivot tables in Laravel and why alphabetical order matters.
Pivot tables connect two tables and their names must be consistent.
You got /4 concepts.