联表要求至少有两张表(除了自己连接自己,自联查询),而且还是存在关系的两张表。
例如:可以建立两张表:文章表、作者表
文章表(article):
id 主键
article_name 文章名称,varchar(50),notnull
author_id 作者id,int,notnull
作者表(author):
id 主键
author_name 作者名称,varcher(20),notnull
创建迁移文件:
php artisan make:migration create_article_table
php artisan make:migration create_author_table
编写迁移文件代码
保存后进行迁移