create table employee
   (employee_name 	varchar(15)	not null primary key,
    street	 	varchar(12)	not null,
    city	 	varchar(15)	not null);

create table company
   (company_name 	varchar(15)	not null primary key,
    city	 	varchar(15)	not null);

create table works
   (employee_name 	varchar(15)	not null primary key,
    company_name 	varchar(15)	not null,
    salary              integer          not null,
    foreign key(company_name) references company(company_name),
    foreign key(employee_name) references employee(employee_name));

create table manages
   (employee_name	varchar(15)	not null primary key,
    manager_name        varchar(15)     not null,
    foreign key(employee_name) references works(employee_name),
    foreign key(manager_name) references works(employee_name));

/* populate relations */

insert into employee	values ('Jones',	'Main',		'Brooklyn');
insert into employee	values ('Smith',	'Main',		'Rye');
insert into employee	values ('Hayes',	'Main',		'Harrison');
insert into employee	values ('Curry',	'First',	'Brooklyn');
insert into employee	values ('Lindsay',	'Park',		'Pittsfield');
insert into employee	values ('Turner',	'Putnam',	'Stamford');
insert into employee	values ('Piazza',	'Palm',		'Harrison');
insert into employee	values ('Snyder',	'Lincoln',	'Rye');
insert into employee	values ('Williams',	'Nassau',	'Palo Alto');
insert into employee	values ('Gates',	'Elm',		'Rye');
insert into employee	values ('Adams',	'Park',		'Pittsfield');
insert into employee	values ('Johnson',	'Alma',		'Palo Alto');
insert into employee	values ('Glenn',	'Sand Hill',	'Palo Alto');
insert into employee	values ('McCoy',	'First',	'Rye');
insert into employee	values ('Wright',	'Safety',	'Rye');
insert into employee	values ('Brooks',	'Senator',	'Brooklyn');
insert into employee	values ('Green',	'Walnut',	'Pittsfield');
insert into employee	values ('Jackson',	'University',	'Brooklyn');
insert into employee	values ('Majeris',	'First',	'Rye');
insert into employee	values ('McBride',	'Safety',	'Rye');
insert into employee	values ('Brady',	'Senator',	'Brooklyn');

insert into company	values ('First Bank',	'Brooklyn');
insert into company	values ('Small Bank',	'Palo Alto');
insert into company	values ('IBM',	 	'Pittsfield');
insert into company	values ('Intel',	'Pittsfield');
insert into company	values ('Microsoft',	'Pittsfield');
insert into company	values ('Boeing',	'Palo Alto');
insert into company	values ('Lockheed',	'Rye');

insert into works	values ('Jones',	'Microsoft',	'40000');
insert into works	values ('Smith',	'Intel',	'30000');
insert into works	values ('Snyder',	'Small Bank',	'20000');
insert into works	values ('Hayes',	'Microsoft',	'35000');
insert into works	values ('Curry',	'First Bank',	'50000');
insert into works	values ('Lindsay',	'Small Bank',	'25000');
insert into works	values ('Turner',	'First Bank',	'28000');
insert into works	values ('Williams',	'Boeing',	'30000');
insert into works	values ('Adams',	'Small Bank',	'15000');
insert into works	values ('Johnson',	'Small Bank',	'22000');
insert into works	values ('Glenn',	'First Bank',	'100000');
insert into works	values ('Wright',	'Boeing',	'80000');
insert into works	values ('Brooks',	'Small Bank',	'25000');
insert into works	values ('Green',	'First Bank',   '15000');
insert into works	values ('Jackson',	'IBM',		'200000');
insert into works	values ('Majeris',	'Lockheed',	'70000');
insert into works	values ('McBride',	'IBM',		'10000');
insert into works	values ('Gates',	'Microsoft',	'1000000');
insert into works	values ('McCoy',	'First Bank',	'15000');
insert into works	values ('Piazza',	'First Bank',	'20000');
insert into works	values ('Brady',	'Boeing',	'66000');

insert into manages	values ('Glenn',	'Green');
insert into manages	values ('Green',	'Turner');
insert into manages	values ('Hayes',	'Jones');
insert into manages	values ('Adams',	'Lindsay');
insert into manages	values ('Gates',	'Jones');
insert into manages	values ('McBride',	'Jackson');
insert into manages	values ('Lindsay',	'Brooks');



