﻿INSERT INTO SUBJECTS(NAME)
SELECT 'Russkiy yazik' FROM DUAL
UNION ALL
SELECT 'Matematika' FROM DUAL
UNION ALL
SELECT 'Fizika' FROM DUAL
UNION ALL
SELECT 'Informatika' FROM DUAL
UNION ALL
SELECT 'Angliyskiy yazik' FROM DUAL
UNION ALL
SELECT 'Istoriya' FROM DUAL
UNION ALL
SELECT 'Obhestvoznanie' FROM DUAL
UNION ALL
SELECT 'Himiya' FROM DUAL
UNION ALL
SELECT 'Biologiya' FROM DUAL
UNION ALL
SELECT 'Literatura' FROM DUAL;

INSERT INTO BRANCHES(NAME)
SELECT 'Dnevnoe' FROM DUAL
UNION ALL
SELECT 'Vechernee' FROM DUAL
UNION ALL
SELECT 'Zaochnoe' FROM DUAL;

INSERT INTO ORDERS_ITEMS(NAME,ITEM_NUMBER)
SELECT 'Pobediteli i prizery olimpiad', '1' FROM DUAL
UNION ALL
SELECT 'Imeushie lgoty', '2' FROM DUAL
UNION ALL
SELECT 'Osnovnoy priem', '3' FROM DUAL;

INSERT INTO SPECIALTIES(NAME,CODE)
SELECT 'Prikladnaya matematika i informatika', '01.03.02' FROM DUAL
UNION ALL
SELECT 'Informatika i vichislitelnaya technika', '09.03.01' FROM DUAL
UNION ALL
SELECT 'Prikladnaya informatika', '09.03.03' FROM DUAL
UNION ALL
SELECT 'Programmnaya ingeneria', '09.03.04' FROM DUAL
UNION ALL
SELECT 'Informacionnaya bezopasnost', '10.03.01' FROM DUAL
UNION ALL
SELECT 'Priborostroenie', '12.03.01' FROM DUAL
UNION ALL
SELECT 'Optotechnika', '12.03.02' FROM DUAL
UNION ALL
SELECT 'Tehnicheskaya fizika', '16.03.01' FROM DUAL
UNION ALL
SELECT 'Menegment', '38.03.02' FROM DUAL
UNION ALL
SELECT 'Intellectualnie sistemy v gumanitarnoy sfere', '45.03.04' FROM DUAL;

INSERT INTO DEPARTMENT_TYPES(NAME)
SELECT 'University' FROM DUAL
UNION ALL 
SELECT 'Faculty' FROM DUAL
UNION ALL
SELECT 'Cafedre' FROM DUAL;



INSERT INTO DEPARTMENTS(NAME,DEPARTMENT_ID,DEPARTMENT_TYPE_ID, CODE, ABBR)
SELECT 'University ITMO',NULL, 
(SELECT ID FROM DEPARTMENT_TYPES WHERE NAME='University'),777, 'ITMO' FROM DUAL;
INSERT INTO DEPARTMENTS(NAME,DEPARTMENT_ID,DEPARTMENT_TYPE_ID, CODE, ABBR)
SELECT 'Estestvenno nauchniy Faculty', 
(SELECT ID FROM DEPARTMENTS WHERE CODE=777), 
(SELECT ID FROM DEPARTMENT_TYPES WHERE NAME='Faculty'),100, 'ENF' FROM DUAL;
INSERT INTO DEPARTMENTS(NAME,DEPARTMENT_ID,DEPARTMENT_TYPE_ID, CODE, ABBR)
SELECT 'Faculty informacionnih tehnologiy i programmirovaniya', 
(SELECT ID FROM DEPARTMENTS WHERE CODE=777), 
(SELECT ID FROM DEPARTMENT_TYPES WHERE NAME='Faculty'), 150, 'FITiP' FROM DUAL;
INSERT INTO DEPARTMENTS(NAME,DEPARTMENT_ID,DEPARTMENT_TYPE_ID, CODE, ABBR)
SELECT 'Faculty komputernih tehnologiy i upravlenia', 
(SELECT ID FROM DEPARTMENTS WHERE CODE=777), 
(SELECT ID FROM DEPARTMENT_TYPES WHERE NAME='Faculty'), 200, 'FKTiU' FROM DUAL;
INSERT INTO DEPARTMENTS(NAME,DEPARTMENT_ID,DEPARTMENT_TYPE_ID, CODE, ABBR)
SELECT 'Faculty fotoniki i optoinformatiki', 
(SELECT ID FROM DEPARTMENTS WHERE CODE=777), 
(SELECT ID FROM DEPARTMENT_TYPES WHERE NAME='Faculty'), 250, 'FFiOI' FROM DUAL;
INSERT INTO DEPARTMENTS(NAME,DEPARTMENT_ID,DEPARTMENT_TYPE_ID, CODE, ABBR)
SELECT 'Faculty optico-informacionnih sistem', 
(SELECT ID FROM DEPARTMENTS WHERE CODE=777), 
(SELECT ID FROM DEPARTMENT_TYPES WHERE NAME='Faculty'), 300, 'FOIST' FROM DUAL;
INSERT INTO DEPARTMENTS(NAME,DEPARTMENT_ID,DEPARTMENT_TYPE_ID, CODE, ABBR)
SELECT 'Ingenerno fizicheskiy Faculty', 
(SELECT ID FROM DEPARTMENTS WHERE CODE=777), 
(SELECT ID FROM DEPARTMENT_TYPES WHERE NAME='Faculty'), 350, 'IFF' FROM DUAL;
INSERT INTO DEPARTMENTS(NAME,DEPARTMENT_ID,DEPARTMENT_TYPE_ID, CODE, ABBR)
SELECT 'Cafedre vishey matematiki - 1', 
(SELECT ID FROM DEPARTMENTS WHERE CODE=100), 
(SELECT ID FROM DEPARTMENT_TYPES WHERE NAME='Cafedre'), 101, 'VM-1' FROM DUAL;
INSERT INTO DEPARTMENTS(NAME,DEPARTMENT_ID,DEPARTMENT_TYPE_ID, CODE, ABBR)
SELECT 'Cafedre komputernih tehnologiy', 
(SELECT ID FROM DEPARTMENTS WHERE CODE=150), 
(SELECT ID FROM DEPARTMENT_TYPES WHERE NAME='Cafedre'), 151, 'KT' FROM DUAL;
INSERT INTO DEPARTMENTS(NAME,DEPARTMENT_ID,DEPARTMENT_TYPE_ID, CODE, ABBR)
SELECT 'Cafedre vichislitelnoy tehniki', 
(SELECT ID FROM DEPARTMENTS WHERE CODE=200), 
(SELECT ID FROM DEPARTMENT_TYPES WHERE NAME='Cafedre'), 201, 'VT' FROM DUAL;
INSERT INTO DEPARTMENTS(NAME,DEPARTMENT_ID,DEPARTMENT_TYPE_ID, CODE, ABBR)
SELECT 'Cafedre komputernoy fotoniki i videoinformatiki', 
(SELECT ID FROM DEPARTMENTS WHERE CODE=250), 
(SELECT ID FROM DEPARTMENT_TYPES WHERE NAME='Cafedre'), 251, 'KFiVI' FROM DUAL;
INSERT INTO DEPARTMENTS(NAME,DEPARTMENT_ID,DEPARTMENT_TYPE_ID, CODE, ABBR)
SELECT 'Cafedre informacionnih sistem', 
(SELECT ID FROM DEPARTMENTS WHERE CODE=150), 
(SELECT ID FROM DEPARTMENT_TYPES WHERE NAME='Cafedre'), 152, 'IS' FROM DUAL;
INSERT INTO DEPARTMENTS(NAME,DEPARTMENT_ID,DEPARTMENT_TYPE_ID, CODE, ABBR)
SELECT 'Cafedre informatiki i pricladnoy matematiki', 
(SELECT ID FROM DEPARTMENTS WHERE CODE=200), 
(SELECT ID FROM DEPARTMENT_TYPES WHERE NAME='Cafedre'), 202, 'IPM' FROM DUAL;
INSERT INTO DEPARTMENTS(NAME,DEPARTMENT_ID,DEPARTMENT_TYPE_ID, CODE, ABBR)
SELECT 'Cafedre bezopasnih informacionnih tehnologiy', 
(SELECT ID FROM DEPARTMENTS WHERE CODE=200), 
(SELECT ID FROM DEPARTMENT_TYPES WHERE NAME='Cafedre'), 203, 'BIT' FROM DUAL;
INSERT INTO DEPARTMENTS(NAME,DEPARTMENT_ID,DEPARTMENT_TYPE_ID, CODE, ABBR)
SELECT 'Cafedre intellectualnih tehnologiy v gumanitarnoy sfere',
(SELECT ID FROM DEPARTMENTS WHERE CODE=100), 
(SELECT ID FROM DEPARTMENT_TYPES WHERE NAME='Cafedre'), 102, 'ITGS' FROM DUAL;


INSERT INTO PROGRAMS(SPEC_ID,BRANCH_ID)
SELECT (SELECT ID FROM SPECIALTIES WHERE CODE = '01.03.02'),
(SELECT ID FROM BRANCHES WHERE NAME='Dnevnoe') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM SPECIALTIES WHERE CODE = '01.03.02'),
(SELECT ID FROM BRANCHES WHERE NAME='Vechernee') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM SPECIALTIES WHERE CODE = '01.03.02'),
(SELECT ID FROM BRANCHES WHERE NAME='Zaochnoe') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM SPECIALTIES WHERE CODE = '09.03.01'),
(SELECT ID FROM BRANCHES WHERE NAME='Dnevnoe') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM SPECIALTIES WHERE CODE = '09.03.01'),
(SELECT ID FROM BRANCHES WHERE NAME='Vechernee') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM SPECIALTIES WHERE CODE = '09.03.01'),
(SELECT ID FROM BRANCHES WHERE NAME='Zaochnoe') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM SPECIALTIES WHERE CODE = '09.03.03'),
(SELECT ID FROM BRANCHES WHERE NAME='Dnevnoe') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM SPECIALTIES WHERE CODE = '09.03.03'),
(SELECT ID FROM BRANCHES WHERE NAME='Vechernee') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM SPECIALTIES WHERE CODE = '09.03.03'),
(SELECT ID FROM BRANCHES WHERE NAME='Zaochnoe') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM SPECIALTIES WHERE CODE = '09.03.04'),
(SELECT ID FROM BRANCHES WHERE NAME='Dnevnoe') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM SPECIALTIES WHERE CODE = '09.03.04'),
(SELECT ID FROM BRANCHES WHERE NAME='Vechernee') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM SPECIALTIES WHERE CODE = '09.03.04'),
(SELECT ID FROM BRANCHES WHERE NAME='Zaochnoe') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM SPECIALTIES WHERE CODE = '10.03.01'),
(SELECT ID FROM BRANCHES WHERE NAME='Dnevnoe') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM SPECIALTIES WHERE CODE = '10.03.01'),
(SELECT ID FROM BRANCHES WHERE NAME='Vechernee') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM SPECIALTIES WHERE CODE = '10.03.01'),
(SELECT ID FROM BRANCHES WHERE NAME='Zaochnoe') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM SPECIALTIES WHERE CODE = '12.03.01'),
(SELECT ID FROM BRANCHES WHERE NAME='Dnevnoe') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM SPECIALTIES WHERE CODE = '12.03.01'),
(SELECT ID FROM BRANCHES WHERE NAME='Vechernee') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM SPECIALTIES WHERE CODE = '12.03.01'),
(SELECT ID FROM BRANCHES WHERE NAME='Zaochnoe') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM SPECIALTIES WHERE CODE = '12.03.02'),
(SELECT ID FROM BRANCHES WHERE NAME='Dnevnoe') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM SPECIALTIES WHERE CODE = '12.03.02'),
(SELECT ID FROM BRANCHES WHERE NAME='Vechernee') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM SPECIALTIES WHERE CODE = '12.03.02'),
(SELECT ID FROM BRANCHES WHERE NAME='Zaochnoe') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM SPECIALTIES WHERE CODE = '16.03.01'),
(SELECT ID FROM BRANCHES WHERE NAME='Dnevnoe') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM SPECIALTIES WHERE CODE = '16.03.01'),
(SELECT ID FROM BRANCHES WHERE NAME='Vechernee') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM SPECIALTIES WHERE CODE = '16.03.01'),
(SELECT ID FROM BRANCHES WHERE NAME='Zaochnoe') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM SPECIALTIES WHERE CODE = '38.03.02'),
(SELECT ID FROM BRANCHES WHERE NAME='Dnevnoe') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM SPECIALTIES WHERE CODE = '38.03.02'),
(SELECT ID FROM BRANCHES WHERE NAME='Vechernee') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM SPECIALTIES WHERE CODE = '38.03.02'),
(SELECT ID FROM BRANCHES WHERE NAME='Zaochnoe') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM SPECIALTIES WHERE CODE = '45.03.04'),
(SELECT ID FROM BRANCHES WHERE NAME='Dnevnoe') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM SPECIALTIES WHERE CODE = '45.03.04'),
(SELECT ID FROM BRANCHES WHERE NAME='Vechernee') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM SPECIALTIES WHERE CODE = '45.03.04'),
(SELECT ID FROM BRANCHES WHERE NAME='Zaochnoe') FROM DUAL;


INSERT INTO DEPARTMENTPROGRAM(PROGRAM_ID,DEPARTMENT_ID)
SELECT (SELECT ID FROM PROGRAMS WHERE SPEC_ID=
(SELECT ID FROM SPECIALTIES WHERE CODE='01.03.02') AND
BRANCH_ID = (SELECT ID FROM BRANCHES WHERE NAME='Dnevnoe')),
(SELECT ID FROM DEPARTMENTS WHERE ABBR='VM-1') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM PROGRAMS WHERE SPEC_ID=
(SELECT ID FROM SPECIALTIES WHERE CODE='01.03.02') AND
BRANCH_ID = (SELECT ID FROM BRANCHES WHERE NAME='Vechernee')),
(SELECT ID FROM DEPARTMENTS WHERE ABBR='VM-1') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM PROGRAMS WHERE SPEC_ID=
(SELECT ID FROM SPECIALTIES WHERE CODE='01.03.02') AND
BRANCH_ID = (SELECT ID FROM BRANCHES WHERE NAME='Zaochnoe')),
(SELECT ID FROM DEPARTMENTS WHERE ABBR='VM-1') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM PROGRAMS WHERE SPEC_ID=
(SELECT ID FROM SPECIALTIES WHERE CODE='01.03.02') AND
BRANCH_ID = (SELECT ID FROM BRANCHES WHERE NAME='Dnevnoe')),
(SELECT ID FROM DEPARTMENTS WHERE ABBR='KT') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM PROGRAMS WHERE SPEC_ID=
(SELECT ID FROM SPECIALTIES WHERE CODE='01.03.02') AND
BRANCH_ID = (SELECT ID FROM BRANCHES WHERE NAME='Vechernee')),
(SELECT ID FROM DEPARTMENTS WHERE ABBR='KT') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM PROGRAMS WHERE SPEC_ID=
(SELECT ID FROM SPECIALTIES WHERE CODE='01.03.02') AND
BRANCH_ID = (SELECT ID FROM BRANCHES WHERE NAME='Zaochnoe')),
(SELECT ID FROM DEPARTMENTS WHERE ABBR='KT') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM PROGRAMS WHERE SPEC_ID=
(SELECT ID FROM SPECIALTIES WHERE CODE='09.03.01') AND
BRANCH_ID = (SELECT ID FROM BRANCHES WHERE NAME='Dnevnoe')),
(SELECT ID FROM DEPARTMENTS WHERE ABBR='VT') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM PROGRAMS WHERE SPEC_ID=
(SELECT ID FROM SPECIALTIES WHERE CODE='09.03.01') AND
BRANCH_ID = (SELECT ID FROM BRANCHES WHERE NAME='Vechernee')),
(SELECT ID FROM DEPARTMENTS WHERE ABBR='VT') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM PROGRAMS WHERE SPEC_ID=
(SELECT ID FROM SPECIALTIES WHERE CODE='09.03.01') AND
BRANCH_ID = (SELECT ID FROM BRANCHES WHERE NAME='Zaochnoe')),
(SELECT ID FROM DEPARTMENTS WHERE ABBR='VT') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM PROGRAMS WHERE SPEC_ID=
(SELECT ID FROM SPECIALTIES WHERE CODE='09.03.03') AND
BRANCH_ID = (SELECT ID FROM BRANCHES WHERE NAME='Dnevnoe')),
(SELECT ID FROM DEPARTMENTS WHERE ABBR='KFiVI') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM PROGRAMS WHERE SPEC_ID=
(SELECT ID FROM SPECIALTIES WHERE CODE='09.03.03') AND
BRANCH_ID = (SELECT ID FROM BRANCHES WHERE NAME='Vechernee')),
(SELECT ID FROM DEPARTMENTS WHERE ABBR='KFiVI') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM PROGRAMS WHERE SPEC_ID=
(SELECT ID FROM SPECIALTIES WHERE CODE='09.03.03') AND
BRANCH_ID = (SELECT ID FROM BRANCHES WHERE NAME='Zaochnoe')),
(SELECT ID FROM DEPARTMENTS WHERE ABBR='KFiVI') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM PROGRAMS WHERE SPEC_ID=
(SELECT ID FROM SPECIALTIES WHERE CODE='09.03.03') AND
BRANCH_ID = (SELECT ID FROM BRANCHES WHERE NAME='Dnevnoe')),
(SELECT ID FROM DEPARTMENTS WHERE ABBR='IS') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM PROGRAMS WHERE SPEC_ID=
(SELECT ID FROM SPECIALTIES WHERE CODE='09.03.03') AND
BRANCH_ID = (SELECT ID FROM BRANCHES WHERE NAME='Vechernee')),
(SELECT ID FROM DEPARTMENTS WHERE ABBR='IS') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM PROGRAMS WHERE SPEC_ID=
(SELECT ID FROM SPECIALTIES WHERE CODE='09.03.03') AND
BRANCH_ID = (SELECT ID FROM BRANCHES WHERE NAME='Zaochnoe')),
(SELECT ID FROM DEPARTMENTS WHERE ABBR='IS') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM PROGRAMS WHERE SPEC_ID=
(SELECT ID FROM SPECIALTIES WHERE CODE='09.03.04') AND
BRANCH_ID = (SELECT ID FROM BRANCHES WHERE NAME='Dnevnoe')),
(SELECT ID FROM DEPARTMENTS WHERE ABBR='IPM') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM PROGRAMS WHERE SPEC_ID=
(SELECT ID FROM SPECIALTIES WHERE CODE='09.03.04') AND
BRANCH_ID = (SELECT ID FROM BRANCHES WHERE NAME='Vechernee')),
(SELECT ID FROM DEPARTMENTS WHERE ABBR='IPM') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM PROGRAMS WHERE SPEC_ID=
(SELECT ID FROM SPECIALTIES WHERE CODE='09.03.04') AND
BRANCH_ID = (SELECT ID FROM BRANCHES WHERE NAME='Zaochnoe')),
(SELECT ID FROM DEPARTMENTS WHERE ABBR='IPM') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM PROGRAMS WHERE SPEC_ID=
(SELECT ID FROM SPECIALTIES WHERE CODE='10.03.01') AND
BRANCH_ID = (SELECT ID FROM BRANCHES WHERE NAME='Dnevnoe')),
(SELECT ID FROM DEPARTMENTS WHERE ABBR='VT') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM PROGRAMS WHERE SPEC_ID=
(SELECT ID FROM SPECIALTIES WHERE CODE='10.03.01') AND
BRANCH_ID = (SELECT ID FROM BRANCHES WHERE NAME='Vechernee')),
(SELECT ID FROM DEPARTMENTS WHERE ABBR='VT') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM PROGRAMS WHERE SPEC_ID=
(SELECT ID FROM SPECIALTIES WHERE CODE='10.03.01') AND
BRANCH_ID = (SELECT ID FROM BRANCHES WHERE NAME='Zaochnoe')),
(SELECT ID FROM DEPARTMENTS WHERE ABBR='VT') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM PROGRAMS WHERE SPEC_ID=
(SELECT ID FROM SPECIALTIES WHERE CODE='12.03.02') AND
BRANCH_ID = (SELECT ID FROM BRANCHES WHERE NAME='Dnevnoe')),
(SELECT ID FROM DEPARTMENTS WHERE ABBR='KFiVI') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM PROGRAMS WHERE SPEC_ID=
(SELECT ID FROM SPECIALTIES WHERE CODE='12.03.02') AND
BRANCH_ID = (SELECT ID FROM BRANCHES WHERE NAME='Vechernee')),
(SELECT ID FROM DEPARTMENTS WHERE ABBR='KFiVI') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM PROGRAMS WHERE SPEC_ID=
(SELECT ID FROM SPECIALTIES WHERE CODE='12.03.02') AND
BRANCH_ID = (SELECT ID FROM BRANCHES WHERE NAME='Zaochnoe')),
(SELECT ID FROM DEPARTMENTS WHERE ABBR='KFiVI') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM PROGRAMS WHERE SPEC_ID=
(SELECT ID FROM SPECIALTIES WHERE CODE='45.03.04') AND
BRANCH_ID = (SELECT ID FROM BRANCHES WHERE NAME='Dnevnoe')),
(SELECT ID FROM DEPARTMENTS WHERE ABBR='ITGS') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM PROGRAMS WHERE SPEC_ID=
(SELECT ID FROM SPECIALTIES WHERE CODE='45.03.04') AND
BRANCH_ID = (SELECT ID FROM BRANCHES WHERE NAME='Vechernee')),
(SELECT ID FROM DEPARTMENTS WHERE ABBR='ITGS') FROM DUAL
UNION ALL
SELECT (SELECT ID FROM PROGRAMS WHERE SPEC_ID=
(SELECT ID FROM SPECIALTIES WHERE CODE='45.03.04') AND
BRANCH_ID = (SELECT ID FROM BRANCHES WHERE NAME='Zaochnoe')),
(SELECT ID FROM DEPARTMENTS WHERE ABBR='ITGS') FROM DUAL;

INSERT INTO CITIZENSHIP(NAME) VALUES('Russia');
INSERT INTO CITIZENSHIP(NAME) VALUES('Ukrane');
INSERT INTO CITIZENSHIP(NAME) VALUES('Kazahstan');