mercredi 29 mai 2019

How to normalize a table when I have a key pair type of data

I am making a platform where a trainer will be able to add courses to his profile. But before he adds course there needs to be an application acceptance that needs to be done.

So, I had earlier divided my database into three parts:

users | trainer | course

After a little bit of research, I found that I will have to do database normalization but I am having issues with setting it up.

Now I have trainer table trainer_experience table and trainer_achievements table. Inside trainer experience table I have to save data of the position they wore in and the company name.

My trainer table is this:

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateTrainersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('trainers', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('user_id');
            $table->date('date_of_birth');
            $table->integer('mobile_number');
            $table->longText('address');
            $table->string('id_proof');
            $table->string('id_registration_number');
            $table->string('high_school_name');
            $table->string('graduation_college_name');
            $table->string('graduation_course_name');
            $table->string('post_graduation_college_name');
            $table->string('post_graduation_course_name');
            $table->string('phd_field_of_study');
            $table->string('total_duration_of_training');
            $table->integer('no_of_people_trained');
            $table->boolean('paid_training');
            $table->string('training_category');
            $table->string('course_material_ready');
            $table->string('youtube_link')->nullable();
            $table->string('twitter_link')->nullable();
            $table->string('instagram_link')->nullable();
            $table->string('facebook_link')->nullable();
            $table->string('linkedin_link')->nullable();
            $table->string('blog_link')->nullable();
            $table->string('website_link')->nullable();
            $table->string('meetup_group_link')->nullable();    
            $table->timestamps();

            $table->index('user_id');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('trainers');
    }
}


How do I store the data so, that I can at least retrieve it in the order they have entered? Do I need to make two different tables? What is the best option that I have?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire