CREATE TABLE ACCT_TRANSACTION ( ACCT_TRANS_NUM int, ACCT_TRANS_DATE datetime, CUST_NUMBER int, ACCT_TRANS_TYPE varchar(8), ACCT_TRANS_AMOUNT float(8) ); INSERT INTO ACCT_TRANSACTION VALUES('10003','1/17/2016','10014','charge','329.66'); INSERT INTO ACCT_TRANSACTION VALUES('10004','1/17/2016','10011','charge','615.73'); INSERT INTO ACCT_TRANSACTION VALUES('10006','1/29/2016','10014','payment','329.66'); INSERT INTO ACCT_TRANSACTION VALUES('10007','1/18/2016','10016','charge','277.55'); /* -- */ CREATE TABLE INVOICE ( INV_NUMBER int, CUST_NUMBER int, INV_DATE datetime, INV_SUBTOTAL float(8), INV_TAX float(8), INV_TOTAL float(8), INV_PAY_TYPE varchar(5), INV_PAY_AMOUNT float(8), INV_BALANCE float(8) ); INSERT INTO INVOICE VALUES('1001','10014','1/16/2016','54.92','4.39','59.31','cc','59.31','0'); INSERT INTO INVOICE VALUES('1002','10011','1/16/2016','9.98','0.80','10.78','cash','10.78','0'); INSERT INTO INVOICE VALUES('1003','10012','1/16/2016','270.70','21.66','292.36','cc','292.36','0'); INSERT INTO INVOICE VALUES('1004','10011','1/17/2016','34.87','2.79','37.66','cc','37.66','0'); INSERT INTO INVOICE VALUES('1005','10018','1/17/2016','70.44','5.64','76.08','cc','76.08','0'); INSERT INTO INVOICE VALUES('1006','10014','1/17/2016','397.83','31.83','429.66','cred','100','329.66'); INSERT INTO INVOICE VALUES('1007','10015','1/17/2016','34.97','2.79','37.77','chk','37.77','0'); INSERT INTO INVOICE VALUES('1008','10011','1/17/2016','1033.08','82.65','1115.73','cred','500','615.73'); INSERT INTO INVOICE VALUES('1009','10016','1/18/2016','256.99','20.56','277.55','cred','0','277.55'); /* -- */ CREATE TABLE LINE ( INV_NUMBER int, LINE_NUMBER int, PROD_CODE varchar(10), LINE_UNITS float(8), LINE_PRICE float(8), LINE_AMOUNT float(8) ); INSERT INTO LINE VALUES('1001','1','13-Q2/P2','3','14.99','44.97'); INSERT INTO LINE VALUES('1001','2','23109-HB','1','9.95','9.95'); INSERT INTO LINE VALUES('1002','1','54778-2T','2','4.99','9.98'); INSERT INTO LINE VALUES('1003','1','2238/QPD','4','38.95','155.80'); INSERT INTO LINE VALUES('1003','2','1546-QQ2','1','39.95','39.95'); INSERT INTO LINE VALUES('1003','3','13-Q2/P2','5','14.99','74.95'); INSERT INTO LINE VALUES('1004','1','54778-2T','3','4.99','14.97'); INSERT INTO LINE VALUES('1004','2','23109-HB','2','9.95','19.90'); INSERT INTO LINE VALUES('1005','1','PVC23DRT','12','5.87','70.44'); INSERT INTO LINE VALUES('1006','1','SM-18277','3','6.99','20.97'); INSERT INTO LINE VALUES('1006','2','2232/QTY','1','109.92','109.92'); INSERT INTO LINE VALUES('1006','3','23109-HB','1','9.95','9.95'); INSERT INTO LINE VALUES('1006','4','89-WRE-Q','1','256.99','256.99'); INSERT INTO LINE VALUES('1007','1','13-Q2/P2','2','14.99','29.98'); INSERT INTO LINE VALUES('1007','2','54778-2T','1','4.99','4.99'); INSERT INTO LINE VALUES('1008','1','PVC23DRT','5','5.87','29.35'); INSERT INTO LINE VALUES('1008','2','WR3/TT3','4','119.95','479.80'); INSERT INTO LINE VALUES('1008','3','23109-HB','1','9.95','9.95'); INSERT INTO LINE VALUES('1008','4','89-WRE-Q','2','256.99','513.98'); INSERT INTO LINE VALUES('1009','1','89-WRE-Q','1','256.99','256.99'); /* -- */ CREATE TABLE PRODUCT ( PROD_CODE varchar(10), PROD_DESCRIPT varchar(35), PROD_INDATE datetime, PROD_QOH int, PROD_MIN int, PROD_PRICE float(8), PROD_DISCOUNT float(8), VEND_NUMBER int ); INSERT INTO PRODUCT VALUES('11QER/31','Power painter, 15 psi., 3-nozzle', '11/3/2015', '8', '5', '109.99', '0', '25595'); INSERT INTO PRODUCT VALUES('13-Q2/P2','7.25-in. pwr. saw blade', '12/13/2015', '32', '15', '14.99', '0.05', '21344'); INSERT INTO PRODUCT VALUES('14-Q1/L3','9.00-in. pwr. saw blade', '11/13/2015', '18', '12', '17.49', '0', '21344'); INSERT INTO PRODUCT VALUES('1546-QQ2','Hrd. cloth, 1/4-in., 2x50', '1/15/2016', '15', '8', '39.95', '0', '23119'); INSERT INTO PRODUCT VALUES('1558-QW1','Hrd. cloth, 1/2-in., 3x50', '1/15/2016', '23', '5', '43.99', '0', '23119'); INSERT INTO PRODUCT VALUES('2232/QTY','B&D jigsaw, 12-in. blade', '12/30/2015', '8', '5', '109.92', '0.05', '24288'); INSERT INTO PRODUCT VALUES('2232/QWE','B&D jigsaw, 8-in. blade', '12/24/2015', '6', '5', '99.87', '0.05', '24288'); INSERT INTO PRODUCT VALUES('2238/QPD','B&D cordless drill, 1/2-in.', '1/20/2016', '12', '5', '38.95', '0.05', '25595'); INSERT INTO PRODUCT VALUES('23109-HB','Claw hammer', '1/20/2016', '23', '10', '9.95', '0.1', '21225'); INSERT INTO PRODUCT VALUES('23114-AA','Sledge hammer, 12 lb.', '1/2/2016', '8', '5', '14.40', '0.05', ''); INSERT INTO PRODUCT VALUES('54778-2T','Rat-tail file, 1/8-in. fine', '12/15/2015', '43', '20', '4.99', '0', '21344'); INSERT INTO PRODUCT VALUES('89-WRE-Q','Hicut chain saw, 16 in.', '1/7/2016', '11', '5', '256.99', '0.05', '24288'); INSERT INTO PRODUCT VALUES('PVC23DRT','PVC pipe, 3.5-in., 8-ft', '1/6/2016', '188', '75', '5.87', '0', ''); INSERT INTO PRODUCT VALUES('SM-18277','1.25-in. metal screw, 25', '3/1/2016', '172', '75', '6.99', '0', '21225'); INSERT INTO PRODUCT VALUES('SW-23116','2.5-in. wd. screw, 50', '2/24/2016', '237', '100', '8.45', '0', '21231'); INSERT INTO PRODUCT VALUES('WR3/TT3','Steel matting, 4''x8''x1/6", .5" mesh', '1/17/2016', '18', '5', '119.95', '0.1', '25595'); /* -- */ CREATE TABLE VENDOR ( VEND_NUMBER int, VEND_NAME varchar(15), VEND_CONTACT varchar(50), VEND_AREACODE varchar(3), VEND_PHONE varchar(8), VEND_STATE varchar(2), VEND_ORDER varchar(1) ); INSERT INTO VENDOR VALUES('21225','Bryson, Inc.','Smithson','615','223-3234','TN','Y'); INSERT INTO VENDOR VALUES('21226','SuperLoo, Inc.','Flushing','904','215-8995','FL','N'); INSERT INTO VENDOR VALUES('21231','D&E Supply','Singh','615','228-3245','TN','Y'); INSERT INTO VENDOR VALUES('21344','Gomez Bros.','Ortega','615','889-2546','KY','N'); INSERT INTO VENDOR VALUES('22567','Dome Supply','Smith','901','678-1419','GA','N'); INSERT INTO VENDOR VALUES('23119','Randsets Ltd.','Anderson','901','678-3998','GA','Y'); INSERT INTO VENDOR VALUES('24004','Brackman Bros.','Browning','615','228-1410','TN','N'); INSERT INTO VENDOR VALUES('24288','ORDVA, Inc.','Hakford','615','898-1234','TN','Y'); INSERT INTO VENDOR VALUES('25443','B&K, Inc.','Smith','904','227-0093','FL','N'); INSERT INTO VENDOR VALUES('25501','Damal Supplies','Smythe','615','890-3529','TN','N'); INSERT INTO VENDOR VALUES('25595','Rubicon Systems','Orton','904','456-0092','FL','Y'); CREATE TABLE QOVENDOR ( V_CODE INTEGER PRIMARY KEY, V_NAME VARCHAR(35) NOT NULL, V_CONTACT VARCHAR(15) NOT NULL, V_AREACODE CHAR(3) NOT NULL, V_PHONE CHAR(8) NOT NULL, V_STATE CHAR(2) NOT NULL, V_ORDER CHAR(1) NOT NULL); CREATE TABLE QOPRODUCT ( P_CODE VARCHAR(10) PRIMARY KEY, P_DESCRIPT VARCHAR(35) NOT NULL, P_INDATE DATE NOT NULL, P_QOH NUMERIC NOT NULL, P_MIN NUMERIC NOT NULL, P_PRICE DECIMAL(8,2) NOT NULL, P_DISCOUNT DECIMAL(4,2) NOT NULL, V_CODE INTEGER REFERENCES QOVENDOR, P_MIN_ORDERNUMERIC, P_REORDERNUMERIC); INSERT INTO QOVENDOR VALUES(21225,'Bryson, Inc.' ,'Smithson','615','223-3234','TN','Y'); INSERT INTO QOVENDOR VALUES(21226,'SuperLoo, Inc.' ,'Flushing','904','215-8995','FL','N'); INSERT INTO QOVENDOR VALUES(21231,'D&E Supply' ,'Singh' ,'615','228-3245','TN','Y'); INSERT INTO QOVENDOR VALUES(21344,'Gomez Bros.' ,'Ortega' ,'615','889-2546','KY','N'); INSERT INTO QOVENDOR VALUES(22567,'Dome Supply' ,'Smith' ,'901','678-1419','GA','N'); INSERT INTO QOVENDOR VALUES(23119,'Randsets Ltd.' ,'Anderson','901','678-3998','GA','Y'); INSERT INTO QOVENDOR VALUES(24004,'Brackman Bros.' ,'Browning','615','228-1410','TN','N'); INSERT INTO QOVENDOR VALUES(24288,'ORDVA, Inc.' ,'Hakford' ,'615','898-1234','TN','Y'); INSERT INTO QOVENDOR VALUES(25443,'B&K, Inc.' ,'Smith' ,'904','227-0093','FL','N'); INSERT INTO QOVENDOR VALUES(25501,'Damal Supplies' ,'Smythe' ,'615','890-3529','TN','N'); INSERT INTO QOVENDOR VALUES(25595,'Rubicon Systems' ,'Orton' ,'904','456-0092','FL','Y'); INSERT INTO QOVENDOR VALUES(25596,'Broadmodre' ,'Juarez' ,'615','456-2342','TN','N'); INSERT INTO QOVENDOR VALUES(25597,'Stones River' ,'Smith' ,'615','456-9254','TN','N'); INSERT INTO QOVENDOR VALUES(25598,'Adams Aluminum' ,'James' ,'615','456-4567','TN','N'); INSERT INTO QOVENDOR VALUES(25599,'Bruce Colony' ,'Peter' ,'615','456-8976','TN','N'); INSERT INTO QOPRODUCT VALUES('11QER/31','Power painter, 15 psi., 3-nozzle' ,'03-NOV-2015', 8, 5,109.99,0.00,25595, 25,0); INSERT INTO QOPRODUCT VALUES('13-Q2/P2','7.25-in. pwr. saw blade' ,'13-DEC-2015', 32, 15, 14.99,0.05,21344, 50,0); INSERT INTO QOPRODUCT VALUES('14-Q1/L3','9.00-in. pwr. saw blade' ,'13-NOV-2015', 18, 12, 17.49,0.00,21344, 50,0); INSERT INTO QOPRODUCT VALUES('1546-QQ2','Hrd. cloth, 1/4-in., 2x50' ,'15-JAN-2016', 15, 8, 39.95,0.00,23119, 35,0); INSERT INTO QOPRODUCT VALUES('1558-QW1','Hrd. cloth, 1/2-in., 3x50' ,'15-JAN-2016', 23, 5, 43.99,0.00,23119, 25,0); INSERT INTO QOPRODUCT VALUES('2232/QTY','B\&D jigsaw, 12-in. blade' ,'30-DEC-2015', 8, 5,109.92,0.05,24288, 15,0); INSERT INTO QOPRODUCT VALUES('2232/QWE','B\&D jigsaw, 8-in. blade' ,'24-DEC-2015', 6, 5, 99.87,0.05,24288, 15,0); INSERT INTO QOPRODUCT VALUES('2238/QPD','B\&D cordless drill, 1/2-in.' ,'20-JAN-2016', 12, 5, 38.95,0.05,25595, 12,0); INSERT INTO QOPRODUCT VALUES('23109-HB','Claw hammer' ,'20-JAN-2016', 23, 10, 9.95,0.10,21225, 25,0); INSERT INTO QOPRODUCT VALUES('23114-AA','Sledge hammer, 12 lb.' ,'02-JAN-2016', 8, 5, 14.40,0.05,NULL , 12,0); INSERT INTO QOPRODUCT VALUES('54778-2T','Rat-tail file, 1/8-in. fine' ,'15-DEC-2015', 43, 20, 4.99,0.00,21344, 25,0); INSERT INTO QOPRODUCT VALUES('89-WRE-Q','Hicut chain saw, 16 in.' ,'07-FEB-2016', 11, 5,256.99,0.05,24288, 10,0); INSERT INTO QOPRODUCT VALUES('PVC23DRT','PVC pipe, 3.5-in., 8-ft' ,'20-FEB-2016',188, 75, 5.87,0.00,NULL , 50,0); INSERT INTO QOPRODUCT VALUES('SM-18277','1.25-in. metal screw, 25' ,'01-MAR-2016',172, 75, 6.99,0.00,21225, 50,0); INSERT INTO QOPRODUCT VALUES('SW-23116','2.5-in. wd. screw, 50' ,'24-FEB-2016',237,100, 8.45,0.00,21231,100,0); INSERT INTO QOPRODUCT VALUES('WR3/TT3' ,'Steel matting, 4''x8''x1/6", .5" mesh','17-JAN-2016', 18, 5,119.95,0.10,25595, 10,0); CREATE TABLE CUST_H1 ( CUS_NUM int, CUS_NAME varchar(15), CUS_ADDRESS varchar(20), CUS_STATE varchar(2), CUS_LIMIT float(8), CUS_BAL float(8), CUS_RATING varchar(1), CUS_DUE float(8) ); INSERT INTO CUST_H1 VALUES('10','Sinex, Inc.','12 Main St.','TN','3500','2700','3','1245'); INSERT INTO CUST_H1 VALUES('12','Mynux Corp.','910 Eagle St.','TN','4000','3500','3','3400'); /* -- */ CREATE TABLE CUST_H2 ( CUS_NUM int, CUS_NAME varchar(15), CUS_ADDRESS varchar(20), CUS_STATE varchar(2), CUS_LIMIT float(8), CUS_BAL float(8), CUS_RATING varchar(1), CUS_DUE float(8) ); INSERT INTO CUST_H2 VALUES('15','NBCC Corp.','909 High Ave.','GA','2000','350','2','50'); /* -- */ CREATE TABLE CUST_H3 ( CUS_NUM int, CUS_NAME varchar(15), CUS_ADDRESS varchar(20), CUS_STATE varchar(2), CUS_LIMIT float(8), CUS_BAL float(8), CUS_RATING varchar(1), CUS_DUE float(8) ); INSERT INTO CUST_H3 VALUES('11','Martin Corp.','321 Sunset Blvd.','FL','6000','1200','1','0'); INSERT INTO CUST_H3 VALUES('13','BTBC, Inc.','Rue du Monde','FL','6000','5890','3','1090'); INSERT INTO CUST_H3 VALUES('14','Victory, Inc.','123 Maple St.','FL','1200','550','1','0'); /* -- */ CREATE TABLE CUST_M1 ( CUS_NUM int, CUS_NAME varchar(15), CUS_ADDRESS varchar(20), CUS_STATE varchar(2) ); INSERT INTO CUST_M1 VALUES('10','Sinex, Inc.','12 Main St.','TN'); INSERT INTO CUST_M1 VALUES('12','Mynux Corp.','910 Eagle St.','TN'); /* -- */ CREATE TABLE CUST_M2 ( CUS_NUM int, CUS_LIMIT float(8), CUS_BAL float(8), CUS_RATING varchar(1), CUS_DUE float(8) ); INSERT INTO CUST_M2 VALUES('10','3500','2700','3','1245'); INSERT INTO CUST_M2 VALUES('12','4000','3500','3','3400'); /* -- */ CREATE TABLE CUST_M3 ( CUS_NUM int, CUS_NAME varchar(15), CUS_ADDRESS varchar(20), CUS_STATE varchar(2) ); INSERT INTO CUST_M3 VALUES('15','NBCC Corp.','909 High Ave.','GA'); /* -- */ CREATE TABLE CUST_M4 ( CUS_NUM int, CUS_LIMIT float(8), CUS_BAL float(8), CUS_RATING varchar(1), CUS_DUE float(8) ); INSERT INTO CUST_M4 VALUES('15','2000','350','2','50'); /* -- */ CREATE TABLE CUST_M5 ( CUS_NUM int, CUS_NAME varchar(15), CUS_ADDRESS varchar(20), CUS_STATE varchar(2) ); INSERT INTO CUST_M5 VALUES('11','Martin Corp.','321 Sunset Blvd.','FL'); INSERT INTO CUST_M5 VALUES('13','BTBC, Inc.','Rue du Monde','FL'); INSERT INTO CUST_M5 VALUES('14','Victory, Inc.','123 Maple St.','FL'); /* -- */ CREATE TABLE CUST_M6 ( CUS_NUM int, CUS_LIMIT float(8), CUS_BAL float(8), CUS_RATING varchar(1), CUS_DUE float(8) ); INSERT INTO CUST_M6 VALUES('11','6000','1200','1','0'); INSERT INTO CUST_M6 VALUES('13','6000','5890','3','1090'); INSERT INTO CUST_M6 VALUES('14','1200','550','1','0'); /* -- */ CREATE TABLE CUST_V1 ( CUS_NUM int, CUS_NAME varchar(15), CUS_ADDRESS varchar(20), CUS_STATE varchar(2) ); INSERT INTO CUST_V1 VALUES('10','Sinex, Inc.','12 Main St.','TN'); INSERT INTO CUST_V1 VALUES('11','Martin Corp.','321 Sunset Blvd.','FL'); INSERT INTO CUST_V1 VALUES('12','Mynux Corp.','910 Eagle St.','TN'); INSERT INTO CUST_V1 VALUES('13','BTBC, Inc.','Rue du Monde','FL'); INSERT INTO CUST_V1 VALUES('14','Victory, Inc.','123 Maple St.','FL'); INSERT INTO CUST_V1 VALUES('15','NBCC Corp.','909 High Ave.','GA'); /* -- */ CREATE TABLE CUST_V2 ( CUS_NUM int, CUS_LIMIT float(8), CUS_BAL float(8), CUS_RATING varchar(1), CUS_DUE float(8) ); INSERT INTO CUST_V2 VALUES('10','3500','2700','3','1245'); INSERT INTO CUST_V2 VALUES('11','6000','1200','1','0'); INSERT INTO CUST_V2 VALUES('12','4000','3500','3','3400'); INSERT INTO CUST_V2 VALUES('13','6000','5890','3','1090'); INSERT INTO CUST_V2 VALUES('14','1200','550','1','0'); INSERT INTO CUST_V2 VALUES('15','2000','350','2','50'); CREATE TABLE CUSTOMER ( CUS_NUM int, CUS_NAME varchar(15), CUS_ADDRESS varchar(20), CUS_STATE varchar(2), CUS_LIMIT float(8), CUS_BAL float(8), CUS_RATING varchar(1), CUS_DUE float(8) ); INSERT INTO CUSTOMER VALUES('10','Sinex, Inc.','12 Main St.','TN','3500','2700','3','1245'); INSERT INTO CUSTOMER VALUES('11','Martin Corp.','321 Sunset Blvd.','FL','6000','1200','1','0'); INSERT INTO CUSTOMER VALUES('12','Mynux Corp.','910 Eagle St.','TN','4000','3500','3','3400'); INSERT INTO CUSTOMER VALUES('13','BTBC, Inc.','Rue du Monde','FL','6000','5890','3','1090'); INSERT INTO CUSTOMER VALUES('14','Victory, Inc.','123 Maple St.','FL','1200','550','1','0'); INSERT INTO CUSTOMER VALUES('15','NBCC Corp.','909 High Ave.','GA','2000','350','2','50'); INSERT INTO CUSTOMER VALUES('10936','NBCC Corp.','909 High Ave.','GA','2000','350','2','50'); /* -- */ --At Site C --a) SELECT * FROM CUSTOMER; --=> A remote request --b) SELECT* FROM INVOICE WHEREINV_TOTAL > 1000; -- A remote request --c) SELECT* FROMPRODUCT WHEREPROD_QOH < 10 --=> A distributed request --d) BEGIN TRAN WORK; UPDATE CUSTOMER SET CUS_BAL =CUS_BAL + 100 WHERE CUS_NUM = '10936'; INSERT INTO INVOICE(INV_NUMBER, CUST_NUMBER, INV_DATE, INV_TOTAL) VALUES ('986391', '10936', '15-FEB-2016', 100); INSERT INTO LINE(INV_NUMBER, LINE_NUMBER, LINE_PRICE) VALUES('986391', '1023', 100); UPDATE PRODUCT SET PROD_QOH = PROD_QOH + -1 WHERE VEND_NUMBER = '1023'; COMMIT WORK; --=> A distributed request --e) BEGIN TRAN WORK; INSERT INTO CUSTOMER(CUS_NUM, CUS_NAME, CUS_ADDRESS, CUS_BAL) VALUES ('34210', 'Victor Ephanor', '123 Main St.', 0.00); INSERT INTO INVOICE(INV_NUMBER, CUST_NUMBER, INV_DATE, INV_TOTAL) VALUES ('986434', '34210', '10-AUG-2016', 2.00); COMMIT WORK; --=> A distributed request --At Site A --f) SELECT CUS_NUM, CUS_NAME, INV_TOTAL FROM CUSTOMER, INVOICE WHERE CUSTOMER.CUS_NUM = INVOICE.CUST_NUMBER; --=> A distributed request --g) SELECT * FROM INVOICE WHERE INV_TOTAL > 1000; --=> A remote request --h) SELECT * FROM PRODUCT WHERE PROD_QOH < 10; --=> A distributed request --At Site B --i) SELECT * FROM CUSTOMER; --=> A remote request --j) SELECT * FROM CUSTOMER; SELECT CUS_NAME, INV_TOTAL FROM CUSTOMER, INVOICE WHERE INV_TOTAL > 1000 AND CUSTOMER.CUS_NUM = INVOICE.CUST_NUMBER; --=> A distributed request --k) SELECT * FROM PRODUCT WHERE PROD_QOH < 10; --=> A distributed request