G
G
grabbee2016-03-15 13:36:48
symfony
grabbee, 2016-03-15 13:36:48

Doctrine architecture and link building, how to do it right?

Help advice. There are, let's say, three tables table_user, table_email, table_code.
- `table_user` contains the primary ID field named `user_id`
- further in the `table_email` and `table_code` tables there is a `user_id` field
That is, in the `table_user` table there is neither an `email_id` field nor a `code_id` field at the same time It's easy to use joins to pull out all the data about a user with a single request.
How is this implemented in the Doctrine at the level of declaring links? I just found only a way in which you need to add `email_id`, `code_id` fields to `table_user` ..

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2016-03-15
@grabbee

doctrine philosophy - we project the system based on the interaction of objects, the database is just an implementation detail.
That is, we have User, UserEmail and UserCode objects. The User object has emails and codes fields. Eee everything. If desired, we can make a bidirectional connection and then the UserEmail/UserCode field will appear user, which will contain the owner, but as a rule this is not necessary.

A
Andrey, 2016-03-15
@VladimirAndreev

the easiest way is to create these tables in the database, set up foreign keys and follow this recipe.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question