I have the following Type Address and PhoneNumber:
CREATE TYPE Adress AS Object (Street varchar2(50), PostalC number, Ville varchar2(50)); CREATE TYPE PhoneNumber AS Object (Ind varchar2(3), PhNumber varchar2(20));
If a person can have many children and a child can have only 2 persons as parents what are the modification I need to have in my Person type below :
CREATE TYPE Person; CREATE TYPE Person AS Object ( FirstName varchar2(50), LastName varchar2(50), Adr Address , Father REF Person, Mother REF Person);
Is to correct to have a self reference (Father and Mother) to the same type?
Advertisement
Answer
Is to correct to have a self reference (Father and Mother) to the same type?
Yes, they are all person
.
If a person can have many children and a child can have only 2 persons as parents what are the modification I need to have in my Person type below:
See the answer to your previous question:
CREATE TYPE person; CREATE TYPE person_table AS TABLE OF REF person; CREATE TYPE person AS OBJECT( id NUMBER(12,0), FirstName VARCHAR2(50), LastName VARCHAR2(50), Adr Address, Father REF Person, Mother REF Person, Children person_table );
db<>fiddle here
a child can have only 2 persons as parents
A child can only have 2 people as biological parents; however, it is pretty common these days for parents to separate and enter new relationships and a child may have many step-parents or the parents could give birth via surrogacy.