create table COURSES(course_id integer not null primary key,
                     name varchar2(64),required char(1));
create table STUDENTS(computer_no varchar2(9) not null primary key,
                      first_name varchar2(20),surname varchar2(20),  
                      date_of_birth date,name_in_arabic varchar2(24));
create table UNIONS (union_id integer not null primary key,
                     name varchar2(32) not null);
cReAte table EMPLOYEES (employee_id integer not null primary key,
                        first_name varchar2(20) not null, 
                        surname    varchar2(20) not null,
                        manager     integer references EMPLOYEES);
create table DEPARTMENTS(department_id integer not null primary key,
                         name varchar2(32),
                         parent_department integer not null 
                                      references DEPARTMENTS);
create table PAYCHECKS(order_date date not null,
                  employee integer not null references EMPLOYEES,
                  gross_amount number(10,0),net_amount number(10,0),
                  constraint pk_paychecks primary key(order_date,employee));

create table STAFF(staff_id integer not null primary key,
                   title char(1), 
   constraint fk_staff foreign key (staff_id) references EMPLOYEES);

create table SECTIONS(section_no integer not null,
                      staff_id  integer not null references STAFF,
                      course_id integer not null references COURSES,
     constraint pk_sections primary key(section_no,staff_id,course_id));

create table ENROLLMENTS(student_id varchar2(9) not null references STUDENTS,
                section_number integer not null,
                staff_id integer not null, 
                course_id integer not null, 
constraint fk_enrollments 
     foreign key (section_number,staff_id,course_id)  
                        references SECTIONS(section_no,staff_id,course_id),
constraint pk_enrollments primary key 
     (student_id,section_number,staff_id,course_id));

create table workers
          (worker_id integer not null primary key references EMPLOYEES,
           hourly_rate number(10,2), overtime_rate number(10,2),
           union_id integer not null references UNIONS);
 
create table DEPARTMENT_ASSIGNMENTS
     (department_id integer not null references DEPARTMENTS,
      employee_id integer not null references EMPLOYEES,
      assignment_no integer not null,
      constraint pk_department_assignments 
        primary key (department_id,employee_id,assignment_no));