With Doctrine ORM 2.4 I want to implement something that looks like this example:
Person {
private $name;
private $email;
}
Student extends Person {
private $favoriteTeacher;
}
Teacher extends Person {
private $subjectsTaught;
}
But, I want ONE Person to be able to be a Student and a Teacher at the same time, like a natural person being a student in one situation and a teacher in another.
On the database level that would mean that we have the person's data only ONCE in the system and NOT having to change the email twice when the person's email changes.
The representation on a database level could be something like this:
person:
- id (primary key)
- name
- email
student:
- person_id (primary & foreign key)
- favoriteTeacher
teacher:
- person_id (primary & foreign key)
- subjectsTaught
So the following example data would make total sense:
person: id=1, name=peter, ...
student: person_id=1, ...
teacher: person_id=1, ...
Is there a Doctrine construct that does that? As far as I understood all the alternatives presented here in the doctrine docs are creating two entries for Person, when you have someone being a teacher and a student.