Support the ongoing development of Laravel.io →
Database Eloquent Architecture

I'm trying to track really simple social media stats for some companies. At this stage I'm largely storing just their total audience size on different social media platforms.

Is this structure the best way to do this or is there a more efficient/better way?

Stores the base brand infomation

Schema::create('brands', function(Blueprint $table) {
			$table->increments('id');
			$table->string('name')->unique();
			$table->string('slug')->nullable();
			$table->string('url')->unique();
			$table->integer('total_audience')->unsigned();
			$table->timestamps();
			$table->softDeletes();
		});

Stores information about specific instances of accounts on social networks

Schema::create('brandAccounts', function(Blueprint $table) {
			$table->increments('id');
			$table->integer('brand_id')->unsigned();
			$table->foreign('brand_id')->references('id')->on('brands');
			$table->enum('network', array('facebook', 'twitter', 'instagram','youtube'));
			$table->string('network_id');
			$table->timestamps();
			$table->softDeletes();
		});

Stores individual data points for specific social media accounts.

		Schema::create('brandAccountLogs', function(Blueprint $table) {
			$table->increments('id');
			$table->integer('brand_account_id')->unsigned();
			$table->foreign('brand_account_id')->references('id')->on('brandAccounts');
			$table->integer('log')->unsigned();
			$table->timestamps();
			$table->softDeletes();
		});

I should probably put indexes on the foreign keys too.

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Baadier baadier Joined 12 Nov 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.