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

netzfabrik's avatar

Database structure of templates

Hi at all, i need help to design the database. So in the first step i want price templates for each account. So i've now a table for the templates with name, created_at, e.g. and another table with the values of the pricing templates.

Schema::create('pricing_templates', function (Blueprint $table) {
  $table->increments('id')->primary();
  $table->string('name');
});

Schema::create('pricing_template_values', function (Blueprint $table) {
  $table->increments('id')->primary();
  $table->int('pricing_templates_id')->unsigned();
  $table->string('name');
  $table->float('price');
});

But now i want to set custom values to the prices per user account. And at this step i dont know how it is the best solution. Can anyone help me?

Best, Giuliano

0 likes
1 reply
MortenS's avatar

I can see two possible solutions.

  1. You add a user_id column to pricing_template_values.
  2. You create a pivot table to link users and pricing_template_values (many-to-many relationship).

I can't say which is best for your need. If the name in pricing_template_values is the different for each user, the first solution is fine. Otherwise the second one will be more flexible (but also a bit more complicated to manage).

Please or to participate in this conversation.