Should I add user-profile data as fields or as One-to-One entity in Symfony?

155 views Asked by At

I followed some tutorials about symfony and I just set my users. For technical reasons I cannot use FOSUserBundle yet.

I so have a User entity with credentials : username, plainpassword and password, and I now want to add profile data, such as name, mail, favourite colour, nail length and so on.

In the Symfony documentation, they put the email inside the user provider, but it's not used as credential there.

I wonder now, should I put all my profile data inside the user provider, or should I create a UserProfile entity with name, mail, coulours, etc fields with a One-to-One relationship with Users ?

If one is a bad practice, why ?

1

There are 1 answers

0
Matko Đipalo On BEST ANSWER

I don't think any of your solutions is a bad practice or wrong.

I would prefer putting everything in the User entity if most of my users will have profile data, so there will not be much null fields.

If only some users will have profile data, than I think it is little bit cleaner to make separate entity for UserProfile.