Semistructured Integration, Mediators & Ontologies
When sources speak different data models — XML, JSON/NoSQL, raw web pages — integration needs wrappers to expose them as relations and mediators to hold the global schema. This chapter walks the reverse-engineer → conflict → GAV exercise on a semistructured source, the wrapper machinery behind it, and the ontologies/RDF layer that adds machine-readable semantics.
01 · Setup
Semistructured data & graph models
Semistructured data has some structure, but it is not as prescriptive, regular, or complete as in a traditional DBMS. Web pages (HTML), XML documents and various cloud/NoSQL models are the everyday examples — and they are all different, so they do not lend themselves to easy integration.
The unifying representation is a graph (or tree): labelled nodes, labelled arcs, or both. An XML
document maps naturally onto such a graph, where the irregularity shows plainly — one <model> node
has a rank, another does not. A well-organised graph-based model the course names is OEM (the
Object Exchange Model), used internally by the mediator we meet next.
<producer>
<mn-name>Mercury</mn-name>
<year>1999</year>
<model>
<mo-name>Sable LT</mo-name>
<front-rating>3.84</front-rating>
<side-rating>2.14</side-rating>
<rank>9</rank>
</model>
</producer>The goal is to integrate, query and compare data of different structures — including semistructured data — as if it were all structured, building an overall representation progressively as new sources are discovered.
“As if it were all structured” means an actual translation, and that translation is the graded first step of the semistructured Part II. Click through the document and watch each element land in the relational schema:
One source, three representations
The chapter's car document — deliberately irregular, since one <model> carries a rank and the other does not. Click any element to see what it becomes in the graph and in the relational schema, and which translation rule put it there.
pathproducers / producer / model / rank
| XML | <rank>9</rank> at producers/producer/model/rank |
| Graph | a leaf reached by the edge labelled "rank" |
| Relational | MODEL.rank — NULLABLE |
Rule · This element is present on some siblings and absent on others. That irregularity is exactly what "semistructured" means, and it translates to a NULLABLE column — not a separate table, and not a dropped field.
<rank> under the first model, then select <side-rating>. Both are leaves of the same element, but only one becomes a nullable column — because only one is missing from the other <model>. That difference is not visible in the XML; you have to compare siblings to find it.02 · Architecture
Mediators & the TSIMMIS pattern
Across genuinely different data models, plain GAV/LAV mappings are no longer sufficient: the middleware needs a mediator. Mediation (Wiederhold’s term) bundles the processing to make interfaces work, the knowledge structures that drive data-to-information transformations, and any intermediate storage — and each domain needs its own mediator designed to understand that domain’s semantics.
TSIMMIS — the archetype (Stanford, 1990s)
The first system built on the mediator/wrapper paradigm. A single graph-based internal model (OEM) is managed by the mediator; wrappers do the model-to-model translation from each source (RDBMS, NoSQL, WWW); queries are posed to the mediator in the LOREL language. The mediator knows the semantics of the application domain.
The general architecture is a separation of concerns: the mediator deals with source distribution (which source holds what, how to combine), while each wrapper deals with source heterogeneity and autonomy. A common language runs between them, and each source’s wrapper exports that source’s schema, data and query-processing capabilities.
03 · The exercise
Integrating a semistructured source
Semistructured integration — a Part II in 3 of 16 sessions
The integration exercise arrives in a semistructured flavour in 2016-06-27 (XML), 2017-07-21
(JSON/NoSQL) and 2018-07-09 (XML) — 22 pts each (plus the 2022 combined exercise). It is the same five-step method as the relational
case, with one extra move at the front: reverse-engineer the XML/JSON source and give its
relational translation, assuming a wrapper bridges the two. The recurring graders’ checkpoints are
the DTD/JSON → ER → relational chain, the conflict table, the GAV UNION views with
KeyGen, and the query rewriting.
The lecture’s worked case integrates a relational source with an XML one. The relational source is
ordinary tables (SHOW, CASTMEMBER, CAST, AGENT, ROLE, CASTROLE); the XML source is
described by a DTD:
<!ELEMENT TvShowsDB (TvShow*)>
<!ELEMENT TvShow (Anchor+, Schedule)>
<!ELEMENT Schedule (Day+)>
<!ELEMENT Day (Guest+)>
<!ATTLIST TvShow Title CDATA #REQUIRED Edition CDATA #REQUIRED Duration CDATA #REQUIRED>
<!ATTLIST Anchor Name CDATA #REQUIRED EngagementFee CDATA #REQUIRED AgentPhoneContact CDATA #IMPLIED>
<!ATTLIST Day Date CDATA #REQUIRED Special (0|1) "0">
<!ATTLIST Guest Name CDATA #REQUIRED EngagementFee CDATA #REQUIRED Address CDATA #IMPLIED>1 · Reverse-engineer both sources
Turn the relational schema into ER, and the DTD into ER plus its relational translation —
nesting (TvShow → Schedule → Day → Guest) becomes entities/relationships; a wrapper is assumed
to keep the XML source and this relational counterpart in correspondence (this course does not
implement wrappers).
2a · Related concepts + conflicts
Match Show↔TvShow, CastMember↔Anchor/Guest. Resolve the usual clashes: name (entity
names, FeePerHour↔EngagementFee), key (Code↔Name, Title+Date↔Title+Edition),
structure (agent as entity vs attribute; one Firstname$Lastname string vs two attributes),
cardinality (fee fixed vs fee-varies-per-edition → keep the more general “varies”).
2b–c · Global schema + logical translation
Build the integrated ER (only the TV-show data, since the exercise asks for exactly that), then translate to a global relational schema with single-source attributes kept optional.
3 · Query, GAV mapping, rewriting
Write the query on the global schema; define the GAV UNION views (one branch per source), using
KeyGen(id, source) for identifiers, isSpecial(date) for a derived value, and the string
functions left/position/right to split Firstname$Lastname; then rewrite the query over
the two sources.
Two traps specific to the semistructured case
(1) Splitting the composite name. Anchor.Name = "David$Letterman" must be split into first/last
via left(Name, position('$' in Name) - 1) and right(Name, length(Name) - position('$' in Name)) in
every branch that reads it. (2) Fee that varies per edition/appearance. The XML fee depends on
edition and day, so in the global schema it lives on the Cast relationship, not on the person — keep
the more general structure or you lose information.
Here is a full semistructured exercise to work end to end — an XML (DTD) patent source integrated with a relational one, with the relational translation, conflict table, GAV mapping and rewriting:
04 · Exam-hot
Wrappers for web & semistructured sources
Wrappers & mediators — asked in 2 of 16 sessions
“Define wrappers (and mediators), when they are advised, how they work, and the types introduced in the course” appears in 2016-09-21 and 2022-06-24. Graders want the wrapper = per-source translator vs mediator = global-schema query rewriter distinction, and the web-page-extraction / automatic-generation material below. Trap: giving the wrapper the mediator’s cross-source reconciliation job — a wrapper sees one source only.
A wrapper converts queries into commands the specific source understands (and may extend a source’s query capability — e.g. carrying instructions to solve currency or measure-unit conflicts), then converts the results back into the application’s format. For structured sources (relational ↔ object-oriented) this is easy; for unstructured data it is hard.
For web pages, the wrapper does information extraction: source format is plain text with HTML tags (no semantics), target format is a relational table / XML / JSON (which adds structure, i.e. semantics). It is a software module running an extraction step whose rules exploit the marking tags — much easier when the page’s structure is itself derived from a database.
Hand-built wrappers break
Web sites change often; a layout change can invalidate the extraction rules, and human maintenance of an ad-hoc wrapper is expensive.
Automatic wrapper generation
Better — but only usable when pages are regular to some extent: many pages sharing one structure, e.g. dynamically generated from a DB (data-intensive web sites). The ROADRUNNER project derives the underlying schema from a page class and produces the wrapper.
05 · Semantics
Ontologies, RDF & Linked Data
To recognise data semantics — not just structure — integration reaches for ontologies. An
ontology is a formal, shared specification of a conceptualization: a controlled vocabulary
of terms and their inter-relationships (synonymy, homonymy, hyponymy, IS_A, PART_OF, plus
designer-defined domain relations). In that sense an ER schema or class diagram is a kind of
ontology — with one caution: an ER schema has no values, whereas an ontology also carries instances.
Kinds
Taxonomic — concept hierarchy + predefined relations, a reference vocabulary (e.g. WordNet). Descriptive — concepts via data structures and their interrelationships, closer to databases (domain ontologies).
Structure
Formally — concepts, relations, instances, axioms. Split into a T-Box
(concept/role definitions + axioms) and an A-Box (ground facts, e.g. Father(Tom)).
On the Web, ontologies power the Semantic Web (Berners-Lee): giving information explicit meaning so machines can process and integrate it. The layering the exam may probe:
- XML — surface syntax for structured documents, but imposes no semantic constraints.
- RDF — a data model of triples subject–predicate–object (node → edge → node/literal), serialisable in XML (or Turtle).
- RDF Schema — vocabulary for classes and properties with generalization hierarchies.
- OWL — richer still (class disjointness, cardinality, equality, property characteristics); three sublanguages OWL Lite / DL / Full.
Triples chain, and that is the whole reason a triple store is a graph rather than a three-column table:
RDF, concretely
One triple states one fact: (Church, subClassOf, PlaceOfWorship). Linked Data (W3C) publishes
such triples over HTTP + URIs + RDF so datasets interlink; Linked Open Data is the public
commons of them — DBpedia (from Wikipedia, ~5M concepts / billions of triples), GeoNames, YAGO, FOAF —
navigable at lod-cloud.net. The query language is SPARQL.
Ontologies support integration in two ways: as a semantic aid to schema/instance conflict resolution (via ontology matching — similarity that respects meaning, not just string shape), or instead of a global schema — source ontologies are extracted from the sources and mapped to a domain ontology used directly for querying. Matching must survive mismatches at the language level (syntax, available constructs) and the ontology level (scope, coverage/granularity, modelling paradigm, encoding, homonymy/synonymy). The key subtlety when ontologies meet databases is the Closed-World Assumption (a DB tuple not present is false) versus the Open-World Assumption an ontology makes — the same soundness/completeness tension from the GAV/LAV chapter, now semantic.
Reasoning services (why an ontology is more than a schema)
Over the T-Box: subsumption (is C a subconcept of D?), consistency, satisfiability. Over the A-Box: consistency w.r.t. the T-Box, instance checking (does individual x belong to concept C?), instance retrieval (all individuals in C). These inferences are what let an ontology align and answer over heterogeneous sources — a plain schema cannot reason.
Load-bearing ideas
- Semistructured data (XML, JSON, web) is irregular; represent it as a graph/tree (OEM) and aim to query it as if structured.
- Mediator vs wrapper: the mediator holds the global schema and handles distribution/rewriting; each wrapper handles one source’s heterogeneity (TSIMMIS is the archetype).
- The exercise adds one step to the relational recipe — reverse-engineer the DTD/JSON source and
its relational translation — then proceeds conflict table → GAV
UNIONviews (KeyGen, name splitting, derived functions) → rewriting. - Web wrappers extract structure from tagged text; hand-built ones are fragile, so automatic generation is used on regular, DB-generated pages (ROADRUNNER).
- Ontologies add machine-readable semantics: , T-Box/A-Box, RDF triples, OWL, Linked Open Data, SPARQL; they aid conflict resolution or replace the global schema (mind CWA vs OWA).
- Exam radar: the semistructured integration exercise (DTD/JSON → ER → relational → GAV →
rewriting, with name-splitting and
KeyGen); the wrapper vs mediator definition and web-page extraction / automatic generation.