Here for example there is a sign:

CREATE TABLE "Prixod" ( "ID" serial NOT NULL, "Сomposition" ComprositionPrixod[] NOT NULL, CONSTRAINT Prixod_pk PRIMARY KEY ("ID") ); 

and there are two types:

 Create type ComprositionPrixod AS ( Name character varying, Count numeric, Price numeric ); Create type ComprositiontTransfer AS ( Name character varying, Count numeric ); 

Can I do something like that, so that both types could be entered into a column: Something like: "Сomposition" ComprositionPrixod[] or ComprositiontTransfer[] NOT NULL ?

    1 answer 1

    There is a possibility of type inheritance as in OOP. For example, your CompositionPrixod type may be inherited from CompositionTransfer (I think you understand why). But this possibility is not in all SQL and DBMS dialects. In the postgress, for example, there is no such possibility. There are other, less elegant ways. For example, composition, inner join and a bunch of other crutches. In your case, I would advise using inheritance of TABLES, not types, and in your table specify a foreign key. Example:

     create table Parent ( column1 integer, column2 varchar(80) ); create table Child ( column3 date, ) inherits(Parent); 

    If you need exactly the types, here the comrade answers this question in abundance: https://stackoverflow.com/questions/28294739/derived-type-in-postgresql