Laravel migrations, Eloquent, and config/database.php target MySQL by default in many tutorials—align charset and strict mode with production.
.env database
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_DATABASE=practice
DB_USERNAME=app_rw
DB_PASSWORD=secret
Migration example
Schema::create('orders', function (Blueprint $table) {
$table->id();
$table->foreignId('customer_id')->constrained();
$table->decimal('total', 12, 2);
$table->timestamps();
});Practice: Review in local or staging only.
N+1 queries
Use with() eager loading—EXPLAIN SQL Eloquent generates in debugbar/telescope.
Important interview questions and answers
- Q: strict mode in Laravel?
A: Often enabled in config—matches ONLY_FULL_GROUP_BY in MySQL 8. - Q: Migration vs raw SQL?
A: Migrations version schema in git—preferred for teams.
Self-check
- How Laravel declare foreign key?
- What is N+1?
Pitfall: SQLite dev + MySQL-only JSON functions break at deploy.
Interview prep
- Eloquent N+1?
Missing eager load causes query per row.
- Migrations?
Versioned schema in PHP code.