SQL中foreign key 的reference是原本的表,关于插入导致冲突的问题

Create the following table in your PostgreSQL server and finish two tasks.

create table person (
    ID CHAR(10),
    name CHAR(40),
    mother CHAR(10),
    father CHAR(10),
    PRIMARY KEY (ID),
    FOREIGN KEY (father) REFERENCES person,
    FOREIGN KEY (mother) REFERENCES person
);

问题:
1. Write a stored function to insert records of a family of four and return the number of the rows in person after inserting. The parameters of the stored function must be "(ID1, name of the 1st child, ID2, name of the 2nd child, ID3, father's name, ID4, mother's name )".
2. Write a trigger to meet the following requirement: delete the parents' records when both of the children's records are deleted.

请问上述问题应该怎么做呢?

https://blog.csdn.net/chenqiai0/article/details/7303471/