A
A
alex1592020-04-15 23:35:35
MySQL
alex159, 2020-04-15 23:35:35

How to properly organize the connection between components in the database?

Hello. I am currently rewriting one application, as the previous database schema was terrible.

There are two modules:

  • Blog
  • Companies


Blogs can have both companies and users. Also, each company refers to a specific user.

Frequent operations:
  • A selection of user blogs and companies that belong to him.
  • Checking who owns the blog article, if it's a company then who owns it.


Requirements:
  • Scalability
  • The convenience of use


Technology:
  • MariDB
  • laravel

5e976f64207c6967240947.png
At the moment, I got rid of the link tables by adding a polymorphic link in the Blog table. But it seems that the scheme is not correct, help to achieve the "ideal" structure

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgeny Matveev, 2020-04-16
@alex159

make better two fields in the blogs table: user_id and company_id
so it's more logical and less confusing

M
Mikhail Bobkov, 2020-04-16
@mike_bma

Now everything is ok.
"But it seems that the scheme is not correct" - what exactly does not suit you?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question