我试图跟踪一些公司真正简单的社交媒体统计数据。在这个阶段,我主要在不同的社交媒体平台上存储他们的总观众规模。
这种结构是最好的方法吗?还是更有效/更好的方式?
存储基础品牌信息
public class GenericValidationAttribute: ValidationAttribute
{
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
{
var obj = validationContext.ObjectInstance as IBaseObject;
if(obj == null) return ValidationResult.Success;
if(obj.content < 0)
return new ValidationResult("Content have to be greater than zero!");
return ValidationResult.Success;
}
}
public class SpecificValidationAttribute: GenericValidationAttribute
{
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
{
var res = base.IsValid(value, validationContext);
if(res != ValidationResult.Success) return res;
// Do some specific validation
// ----
return ValidationResult.Success;
}
}
存储有关社交网络上特定帐户实例的信息
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();
});
存储特定社交媒体帐户的各个数据点。
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();
});
我应该把索引放在外键上。