Академический Документы
Профессиональный Документы
Культура Документы
Outline
Templates for Query Patterns Wrapper Generators Filters Other Operations at the Wrapper
user query
result
Warehouse
Combiner
Extractor
Extractor
Source 1
Source 2
query
resul t Mediator
query
resul t
query
Wrapper
query resul t Source 1
query
Wrapper
Wrapper connects a mediator to a source Wrapper (aka adapter) translates incoming queries and outgoing answers Wrappers are defined by templates The wrapper generator creates tables of all possible templates The driver and tables constitute the wrapper
Design a wrapper
Classify the possible queries that the mediator can ask into templates
Templates are queries with parameters that represent constants (e.g., red) Uses the notation T=>S
Templates
Suppose we want to build a wrapper for the source of Dealer 1 Dealer 1
Mediator
AutosMed(serialNo, model, color, autoTrans, dealer)
Templates
N attributes, 2n possible templates Number of templates could grow unreasonably large, it is possible to simplify
Wrapper Generators
A collection of templates is given to the wrapper generator (WG) WG creates a table that holds the various query patterns contained in the templates, and the source queries that are associated with each
Templates
Results
Wrapper generato r
Tabl e
Driver
Queries
Sourc e
Result
Filters
Not always realistic to write a template for every possible form of query To have the wrapper filter the results of queries that it poses to the source The wrapper has a template that returns a superset of what the query wants, then filter the returned tuples at the wrapper and pass only the desired tuples to the mediator
Mediator: find blue Civic and retrieve serial #, transmission type and dealers
SELECT * FROM AutosMed WHERE color = $c; => SELECT serialNo, model, color, autoTrans, dealer1 FROM cars WHERE color = $c; Set $c = blue TempAutos(serialNo, model, color, autoTrans, dealer) SELECT serialNo, autoTrans, dealer FROM TempAutos WHERE model = Civic;
Examples
Mediator: find dealers s.t there are two red cars of the same model, one manual and one automatic Query from mediator to wrapper: SELECT A1.model A1.dealer FROM AutosMed A1, AutosMed A2 WHERE A1.model = A2.model AND A1.color = red AND A2.color = red AND A1.autoTrans = no AND A2.autoTrans = yes;
Example (Continued)
SELECT DISTINCT A1.model, A1.dealer FROM RedAutos A1, RedAutos A2 WHERE A1.model = A2.model AND A1.autoTrans = no AND A2.autoTrans = yes;
Thank You!
The End!