0

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.

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you!In my mysql version of database schema i used foreign keys. But this "inheritance" provided by postgres dbms is not that kind of inheritance i expected...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.