CS157b
Chris Pollett
May 3, 2023
Below are three common techniques for integrating data source:
AutosWarehouse(serialNo, Model, color, autoTrans, dealer)
INSERT INTO AutosWarehouse(serialNo, Model, autoTrans, dealer) SELECT serialNo, model. color, autoTrans, "Dealer 3" FROM Cars;
AutosMediator(serialNo, Model, color, autoTrans, dealer)
SELECT serialNo, model FROM AutosMediator WHERE color = 'red';for Dealer 2 which has the tables Autos(serial, model, color) and Options(serial, option), the mediator would send the query to the Dealer 2's wrapper which would compute the query:
SELECT serial, model FROM Autos WHERE color = 'red';On the other hand, the same query sent to Dealer 3 would result in the query:
SELECT serialNo, model FROM Cars WHERE color = 'red';
SELECT * FROM AutosMediator WHERE color = '$c' => SELECT serialNo, model, color, autoTrans, 'dealer3' FROM Cars WHERE color = '$c'
Sales(serialNo, date, dealer, price) Autos(serialNo, model, color) Dealers(name, city, state, phone)
SELECT state, AVG(price) FROM Sales, Dealers WHERE Sales.dealer = Dealers.name AND date >= '2006-1-04';