I tried almost everything trying to make Entities that represent my database schema and still having full page errors. If someone can give me some light I would appreciated.
Basically we have 2 registration forms, one for the brand and one for the influencer. In each form we ask for the user information PLUS the specific information depending on which form page you are.
DATABASE SCHEMA:
- Role (this table is already populated with the "type" of person they are, either administrator, brand or influencer)
id | name
- User (this table contains the general information of a person, email and password will be used to login)
id | id_role FK| name | phone | email | password | created_at | status
- Brand (this table contains the specific information of a brand which used the brand form for the registry)
id | user_id FK| name_brand | position_id | email_brand | nif_brand | name_firma | phone_brand |
- Position (this table is already populated with positions we display to be selected, e.g, CEO)
id | name
- District (this table is already populated with districts we display to be selected, e.g, NJ)
id | name
- Influencer (this table contains the specific information of a influencer which used the brand form for the registry)
id | user_id FK | surname | date_of_birth | email_brand | district_id FK | gender
MAIN POINTS:
I already tried to use Doctrine annotation and still didn't worked for me, not sure if it's because Im new to this or if Im not structuring the database/entities correctly or even the managing an entity with its associations into the database.
The idea is that ONE user/person can be EITHER a BRAND or INFLUENCER. That is achieved by the role_id which links to the role table. E.g, if i'm in the brand form and try add my information it will add the personal info in the users table and use the role_id 2 to link to the role table. The specific brand information given will then be inserted in the table BRAND using the user PRIMARY KEY to link both tables. (NOT SURE IF THERE'S A MISTAKE HERE, maybe the user should go through the role table and from that table to the specific table, which is not what i'm doing now). In the BRAND table I ask for it's info and coming from the POSITION SELECT in the form I get the FK position_id and link it to the table POSITION.
A different but similar thing happens with the influencer, which will select his district and then i use that district_id to link the districts table.
The problem is always the foreign key associations with doctrine and property's I need to define in the entities. I already don't declare the foreign keys because I'm aware that doctrine handles the FK relations internaly using objects but can't make this to work..
I would appreciate a lot all the help you guys can share. Thank you.