artwork.jpg我們如何處理數據庫模式與唯一具有每種類型數據的圖形類型?
我想開發一個圖形解決方案,但堅持在類型問題上如何將其編碼到數據庫模式。我剛開始瞭解父母和外鍵的概念。
藝術品屬於類別類型,如照片,樂譜,繪畫,雕塑。我所做的事情是爲藝術作品創建了一個表格,併爲類別類型創建了一個表格,並將外部關鍵字鏈接到主要藝術品表格。如果照片具有特定或獨特的信息(如照片格式和拍攝日期)會怎麼樣?爲了規範這一點,我們是否需要一個單獨的表來容納照片信息?
如何轉換圖表模式?請參閱附件artwork.jpg中的圖表。我不僅將藝術作品錶鏈接到類別,每個類別類型還將有一個單獨的表格,以便爲照片,作曲家名稱和樂譜的長度(分鐘)帶來獨特的信息,如照片格式。請幫助闡明這一點。謝謝。
public function up()
{
Schema::create('artwork', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
//this is foreign key to the categories table
$table->integer('category_id')->nullable()->unsigned();
$table->foreign('category_id')->references('id')
->on('categories')
->onDelete('cascade');
$table->string('author');
$table->string('groupcountry');
$table->string('year');
$table->string('description');
});
}
=============================
class CreateCategoriesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('categories', function (Blueprint $table) {
$table->increments('id');
$table->string('category_name');
$table->string('category_description');
});
}
謝謝您沃爾特指着我的資源 – BraveHeart