

create table Plane_Type
( model		varchar(15)	not null,
  capacity	int		not null,
  weight	char(9)		not null,
  constraint Ptypek
    primary key (model)
);

-- create a new empty table Airplane
create table Airplane
( reg 		varchar(15)	not null,
 model  	varchar(15) not null,
 Hang_number int	not null,
  constraint airpk
    primary key (reg),
constraint modelfk
    foreign key (model) references Plane_Type(model),
constraint Hangarfk
    foreign key (Hang_number) references Hangar(Hanq_Number)
);

-- create a new empty table dept_locations
create table owns
( airplane_reg	int		not null,
  owner_ssn	char(10)	not null,
  constraint owns_primary
    primary key (airplane_reg, owner_ssn),
  constraint owns_fk
    foreign key (airplane_reg) references airplane(reg),
	constraint owns_fk2
	foreign key (owner_ssn) references owner(ss)
);

-- create a new empty table Hangar
create table Hangar
( Hang_number	int		not null,
  Capacity	int		not null,
  location	varchar(15),
  dnum		int		not null,
  constraint hangarpk
    primary key (Hang_number)
);

-- create a new empty table works_on
create table works_on
( plane_Model		varchar(15)		not null,
  essn		char(10)		not null,
  constraint Planekey
    primary key (plane_Model,essn),
  constraint workprojfk
    foreign key (plane_Model) references Plane_Type(model),
	  constraint workprojfk2
    foreign key (essn) references employee(ssn)
);


-- create a new empty table dependent
create table flies
( plane_Model		varchar(15)		not null,
  pilot_ssn 	char(10)	not null,
  constraint deppk
    primary key (pilot_ssn, plane_Model),
  constraint depempfk
    foreign key (plane_Model) references employee(ssn),
	  constraint depempfk2
    foreign key (pilot_ssn) references pilot(ssn)
);
create table Employee
( salary		int		not null,
  shift		varchar(10)		not null,
  ssn		char(10),
  address	varchar(25),
  phone		varchar(10),
  name		varchar(15),
  constraint employeepk
    primary key (ssn)
);
create table Pilot
( Restr		int		not null,
  Lic_Num		varchar(10)		not null,
  ssn		char(10),
  address	varchar(25),
  phone		varchar(10),
  name		varchar(15),
  constraint pilot_pk
    primary key (ssn)
);
create table Owner
(
  ssn		char(10)	not null,
  address	varchar(25),
  personal_phone		varchar(10),
  owner_name		varchar(15),
  Corporation_name			varchar(15) not null,
  
  constraint Owner_pk
    primary key (ssn,owner_name)
);
create table Service
(
  Date_code		varchar(9) not null,
  Woodcode	varchar(25) not null,
  hours		varchar(10),
  
  constraint Service_pk
    primary key (Date_code,Woodcode)
);
create table Maintain
(

	Date_code	varchar(9) not null,
	Woodcode	varchar(25) not null,
	employee_ssn char(10),
	
	
	constraint Maintain_Pk
	primary key (Date_code,Woodcode,employee_ssn)
	



);