我需要一些关于我的数据库结构的帮助,我有三个表 - 一个是基本产品信息的产品,第二个是与产品相关的产品变化,产品变化可以是CD,DVD或蓝光,所以基本上它们是特定产品的产品类型 - 例如将是The Matrix是一种可以包含CD音轨,DVD和/或蓝光的产品。
我遇到问题的下一张桌子是特定产品类型的流派列表,我有属于某个产品的流派,例如动作,戏剧,科幻......但是对于音轨或者只是音乐CD我会有不同的类型,例如Rock,Jazz,Pop等......目前我可以输出DVD和Blu-Rays的所有类型但我想只显示特定产品的那些特定类型可能适用于CD类型或DVD类型或蓝光类型
我的表格信息是这样的
产品::
Schema::create('products', function(Blueprint $table)
{
$table->bigIncrements('id')->unsigned();
$table->string('keywords');
$table->string('title', 160);
$table->text('description');
$table->string('slug', 160);
$table->date('release_date');
$table->string('clip', 160)->nullable();
$table->timestamps();
});
ProductVarations ::
Schema::create('productvariations', function(Blueprint $table)
{
$table->bigIncrements('id')->unsigned();
$table->bigInteger('product_id');
$table->string("image", 160)->nullable();
$table->bigInteger('producttype_id')->unsigned();
$table->decimal("price", 5, 2);
$table->integer('quantity')->unsigned();
$table->integer('discount')->default(0)->unsigned();
$table->date("sale_start")->nullable();
$table->date("sale_end")->nullable();
$table->timestamps();
});
ProductTypse ::
Schema::create('producttypes', function(Blueprint $table)
{
$table->bigIncrements('id')->unsigned();
$table->string('slug', 160);
$table->string('title', 160);
$table->string('keywords', 160);
$table->string('description', 160);
$table->timestamps();
});
流派::
Schema::create('genretypes', function(Blueprint $table)
{
$table->bigIncrements('id')->unsigned();
$table->string('slug', 160);
[**$table->enum('type', array('Music', 'Movies')) Not sure about this approach**];
$table->string('title', 160);
$table->timestamps();
});
Product_GenereType :: [产品和流派的重要查找表连接表]
Schema::create('product_genretypes', function(Blueprint $table)
{
$table->bigInteger('product_id')->unsigned();
$table->bigInteger('genretype_id')->unsigned();
$table->unique( array('product_id','genretype_id') );
$table->timestamps();
});