B
B
bx-coder2017-05-26 16:43:51
Database design
bx-coder, 2017-05-26 16:43:51

Custom fields for Laravel models. How to design a database?

Let's say we have some models in our project: Article, news, comment, user. So, it became necessary to add custom fields to these entities (analogue of Custom fields in Bitrix). Each entity can have many and different types of fields (string, number, list, file, boolean).
What is the best way to design a database for such a case in order to make the most of Eloquent "relationships" and avoid "manual" queries?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Mokhirjon Naimov, 2017-05-28
@zvermafia

I don’t know how Bitrix implemented this, but I think Entity–attribute–value model (EAV) will suit you .

V
Vitaly Yushkevich, 2017-05-26
@yushkevichv

Maybe NoSQL is better suited for such tasks? For example, try with Mongo, will it not hurt so much?
In general, such an architecture is very weak and poorly scalable.

V
vism, 2017-05-27
@vism

if you have postgress - jsonb
If muscle - it seems there is something too, but I don't know.
jsonb in postgress works just as fast as nosql databases

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question