我有一个问题,当我们点击商店网站上的颜色时,该产品的卖家会发生变化,该产品的保修也会发生变化,该产品颜色的价格也会发生变化,数据库是如何
我有一个问题,当我们点击商店网站上的颜色时,该产品的卖家会发生变化,该产品的保修会发生变化,该产品颜色的价格也会发生变化,数据库分析是如何实现的?
我所做的就是 color_product
桌子,我必须拥有它。
还有一张 prices
表格,我必须拥有它,因为产品的价格随时可能变化,而且我想在网站上向用户显示价格表。
颜色表
public function up()
{
Schema::create('colors', function (Blueprint $table) {
$table->id();
$table->string('color_name');
$table->string('color_code');
$table->timestamps();
});
}
类别表
public function up()
{
Schema::create('categories', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('latin');
$table->string('slug');
$table->string('awesome')->nullable();
$table->integer('parent_id');
$table->string('image')->nullable();
$table->timestamps();
});
}
产品表
public function up()
{
Schema::create('products', function (Blueprint $table) {
$table->id();
$table->foreignId('brand_id')->constrained()->cascadeOnDelete();
$table->string('title');
$table->string('slug');
$table->string('latin');
$table->string('latin_slug');
$table->integer('product_number')->nullable();
$table->integer('view')->default(0);
$table->integer('order_product')->default(0);
$table->boolean('status');
$table->boolean('publish');
$table->text('introduction');
$table->longText('expert_check');
$table->text('keywords')->nullable();;
$table->text('descriptions')->nullable();
$table->timestamps();
});
}
保修表
public function up()
{
Schema::create('warranties', function (Blueprint $table) {
$table->id();
$table->foreignId('product_id')->constrained()->cascadeOnDelete();
$table->foreignId('color_id')->constrained()->cascadeOnDelete();
$table->string('name');
$table->string('date');
$table->string('time');
$table->string('price');
$table->timestamps();
});
}
价格表
public function up()
{
Schema::create('prices', function (Blueprint $table) {
$table->id();
$table->foreignId('product_id')->constrained()->cascadeOnDelete();
$table->string('value'); //price in here
$table->boolean('is_active')->default(0);
$table->timestamps();
});
}
类别_产品
public function up()
{
Schema::create('category_product', function (Blueprint $table) {
$table->foreignId('category_id')->constrained()->cascadeOnDelete();
$table->foreignId('product_id')->constrained()->cascadeOnDelete();
$table->primary(['category_id' , 'product_id']);
});
}
color_product
public function up()
{
Schema::create('color_product', function (Blueprint $table) {
$table->foreignId('color_id')->constrained()->cascadeOnDelete();
$table->foreignId('product_id')->constrained()->cascadeOnDelete();
$table->primary(['color_id' , 'product_id']);
});
}