Reputation: 387
I'm trying postgres, version 9.2 Can I reference an existing row in base table from inherited one? Example: i have a "person" table and a "student" table which inherits from person. As i understand, if i insert new student, automatically new person is added. But i need to insert first the person data, and then insert a reference to it and student related data.
Upvotes: 0
Views: 79
Reputation: 125254
As i understand, if i insert new student, automatically new person is added
No. Although you can select students by querying the person table, only the student table will be populated after an insert to the student table.
The relationship you want is foreign key not inheritance. Create the person id column in the student table and make it dependent on the person id on the person table.
Upvotes: 2