DROP TABLE property_item;
DROP TABLE item_supplier;
DROP TABLE property_supplier;


CREATE TABLE property_item (
property_no 	VARCHAR2 (5),
item_description	VARCHAR2(15)
);

CREATE TABLE item_supplier (
item_description	VARCHAR2(15),
supplier_no		VARCHAR2(5)
);

CREATE TABLE property_supplier (
property_no 	VARCHAR2 (5),
supplier_no		VARCHAR2(5)
);


INSERT INTO property_item  VALUES ('PG4','Bed');
INSERT INTO property_item  VALUES ('PG4','Chair');
INSERT INTO property_item  VALUES ('PG16','Bed');
INSERT INTO property_item  VALUES ('PG16','Table');
INSERT INTO property_item  VALUES ('PG36','Chair');


INSERT INTO item_supplier  VALUES ('Bed','S1');
INSERT INTO item_supplier  VALUES ('Chair','S2');
INSERT INTO item_supplier  VALUES ('Bed','S2');
INSERT INTO item_supplier  VALUES ('Table','S1');
INSERT INTO item_supplier  VALUES ('Chair','S3');

INSERT INTO property_supplier VALUES ('PG4','S1');
INSERT INTO property_supplier VALUES ('PG4','S2');
INSERT INTO property_supplier VALUES ('PG16','S2');
INSERT INTO property_supplier VALUES ('PG16','S1');
INSERT INTO property_supplier VALUES ('PG36','S3');

SELECT * FROM property_item ;
SELECT * FROM item_supplier ;
SELECT * FROM property_supplier ;


SELECT p.property_no, rpad(p.item_description,8),
	 rpad(i.item_description,8), i.supplier_no,
	 s.property_no, s.supplier_no
FROM property_item p, item_supplier i, property_supplier s
WHERE  p.property_no = s.property_no AND 
	 p.item_description = i.item_description AND 
	 i.supplier_no = s.supplier_no;  
