A
A
Alexey Vesnin2020-04-23 18:34:42
Database design
Alexey Vesnin, 2020-04-23 18:34:42

What is the best way to store UTM tags of different entities in a database?

I have:

1. Orders
2. Applications 3. Messages
from the contact page

etc).

The question arose, how best to organize their storage?

If I just needed to save them, then I would use JSON for example and write to the utm_data field, but I'm not sure if this is a good option if further manipulations with them are required.

Now I'm thinking about the following options:

Option 1. Create three different tables for each entity, for example, order_utm_params, request_utm_params, contactus_utm_params and use the hasMany() relationship

Option 2. Create one table for all entities, for example, utm_paramable and use the morphMany() connection

In the first option, everything seems to be OK, but there are too many tables, in the second there are not many tables, but it will turn out to be a big mess, since there can be a lot of UTM tags how would you do? And why?

Maybe there was a similar experience?

Do not offer separate analytics systems, since I don’t want to fence Yandex.Metrica from the site.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Anton, 2020-04-23
@alexvdv

A one-to-many polymorphic relation or Many-to-many polymorphic relations

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question