dimanche 4 janvier 2015

Should I use foreign keys in my database if I use laravel?


I'm creating a website with Laravel for the first time. I checked relationships documentation today and it seems that Laravel just uses simple SQL queries.



class User extends Eloquent {

public function phone()
{
return $this->hasOne('Phone');
}

}

$phone = User::find(1)->phone;


And it's basically a select * from phones where user_id = 1 query. So the question is, should I use foreign keys anyway in my database to create relationships?





Aucun commentaire:

Enregistrer un commentaire