Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

christopher's avatar

Should i go for one table or multiple tables ?

For example:

I have a Database table with a few rows ( 20 ). I also have three rows with longtext for a description, highlights and more.

Should i place this rows inside one table or should i create a new table for the description ( longtext ), another new table for highlights ( longtext ) and so on ?

Or should i place all rows inside one table ?

Because i think maybe the performance is better if i dont have a row with 20 records or ?

0 likes
3 replies
pmall's avatar

If description or highlight are not connected with another tables, keep all in one table.

christopher's avatar

The description / highlight table would be connected to a documents/pictures table.

So therefore i should go for multiple tables ?

This would be my migration - is this fine ?

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('companies', function(Blueprint $table)
        {
            $table->increments('id');

            $table->integer('user_id')->unsigned();
            $table->foreign('user_id')->references('id')->on('users');

            $table->integer('country_id')->unsigned();
            $table->foreign('country_id')->references('id')->on('countries');

            $table->integer('documents_id')->unsigned();
            $table->foreign('documents_id')->references('id')->on('documents');

            $table->integer('description_id')->unsigned();
            $table->foreign('description_id')->references('id')->on('descriptions');

            $table->integer('highlights_id')->unsigned();
            $table->foreign('highlights_id')->references('id')->on('highlights');

            $table->integer('attractions_id')->unsigned();
            $table->foreign('attractions_id')->references('id')->on('attractions');

            $table->string('name')->nullable();
            $table->string('picture')->nullable();
            $table->string('website')->nullable();
            $table->string('primary_email')->nullable();
            $table->string('email')->nullable();
            $table->string('skype')->nullable();
            $table->string('phone')->nullable();
            $table->string('mobile')->nullable();
            $table->string('adress')->nullable();
            $table->string('line2')->nullable();
            $table->string('street')->nullable();
            $table->string('city')->nullable();
            $table->string('zip_code')->nullable();
            $table->string('slug');
            $table->timestamps();

            $table->engine = 'InnoDB';
        });

        Schema::create('description', function(Blueprint $table)
        {
            $table->increments('id');
            $table->longText('content');
            $table->engine = 'InnoDB';
        });

        Schema::create('highlights', function(Blueprint $table)
        {
            $table->increments('id');
            $table->longText('content');
            $table->engine = 'InnoDB';
        });

        Schema::create('attractions', function(Blueprint $table)
        {
            $table->increments('id');
            $table->longText('content');
            $table->engine = 'InnoDB';
        });

    }
JarekTkaczyk's avatar

@hostianer Mind that this

$table->foreign('description_id')->references('id')->on('descriptions');

requires from you to use

$table->integer('description_id')->unsigned();

otherwise you will get db error during adding foreign key.

And about the original question - how many rows do you have that you are worrying about performance and how do you query this table?

Please or to participate in this conversation.