Posts

Showing posts from August, 2019
abc /*dummy type for co-dependant objects*/ create type dep_t_k / /*employee object*/ create type emp_t_k as object( EMPNO char(6), FIRSTNAME varchar(12), LASTNAME varchar(15), WORKDEPT ref dep_t_k, SEX char(1), BIRTHDATE date, SALARY number(8,2) ) / /*department object - replace dummy type (same name difference as object)*/ create type dep_t_k as object( DEPTNO char(3), DEPTNAME varchar(36), MGRNO ref emp_t_k, ADMRDEPT ref dep_t_k ) / /*employee table*/ create table OREMP_k of emp_t_k( constraint OREMP_k_pk primary key(EMPNO), constraint OREMP_k_nn1 FIRSTNAME not null, constraint OREMP_k_nn2 LASTNAME not null, constraint OREMP_k_chk1 check(Sex in('M','m','F','f')) ) / /*department table*/ create table ORDEPT_k of dep_t_k( constraint ORDEPT_k_pk primary key(DEPTNO), constraint ORDEPT_k_nn1 DEPTNAME not null ) / /*add references to employee table*/ alter table OREMP_k add constraint OREMP_k_fk1 foreign key(WORKDEPT) references