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

youssefy's avatar

Additional relation(column) or nested relationships

Assuming I have three models (Client -> Project -> Task) and I want to retrieve client informations of a task is it better to have an additional relation between task and client by adding column in table tasks(client_id) instead of using three joins or with... every-time, this is the conclusion that I've come to :

  • Pros: Easy to retrieve data specifically when you need to use complex queries ex: getting statistics..), better performance, make life easier.
  • Cons: Having unnecessary duplicate data, if you need to move tasks to another project both both project and tasks need to be updated, maybe bad practice for database structure.

is that good for an application that need to be scalable(add new features in future), could something go wrong or cause problems in futures.

0 likes
1 reply
Tray2's avatar

No, you should not have that added column in the tasks table.

A client can have many projects. A project has many tasks.

A client has many tasks through the project and can have tasks in many projects.

Try to keep the data in a single place and use the relations between the tables.

1 like

Please or to participate in this conversation.