|
/ modules / paradigms / Adaptor_Relationship.py
SYNOPSIS
Adaptor_Relationship (table, idColumn, joinColumn, cardinality,
paradigm)
table
A main table to query, e.g., "item".
idColumn
The table's item identifier column (i.e., the column to
be selected), e.g., "item_id".
joinColumn
The column to INNER JOIN on, e.g., "author_id".
cardinality
A Cardinality object representing the overall
cardinality of the combined expression.
paradigm
The underlying paradigm.
DESCRIPTION
Adds an inner equijoin relationship to queries returned by an
underlying paradigm. This adaptor is useful in situations in
which a bucket is implemented by placing a constraint against a
database entity that has an indirect relationship to collection
items.
For example, consider a schema with 'item' and 'author' tables
representing collection items and item authors, respectively,
and an 'authorship' table that represents the many-to-many
relationship between collection items and item authors.
CREATE TABLE item (
item_id INTEGER NOT NULL,
...,
PRIMARY KEY (item_id)
);
CREATE TABLE authorship (
item_id INTEGER NOT NULL,
author_id INTEGER NOT NULL,
FOREIGN KEY (item_id) REFERENCES item,
FOREIGN KEY (author_id) REFERENCES author
);
CREATE TABLE author (
author_id INTEGER NOT NULL,
...,
PRIMARY KEY (author_id)
);
A bucket for authors of collection items can be expressed by
defining a paradigm for authors, and then relating authors to
collection items, as in:
P.Adaptor_Relationship(
"authorship",
"item_id",
"author_id",
UT.Cardinality("1+"),
P.some_underlying_paradigm("author", "author_id", ...))
The underlying paradigm must return, given an appropriate atomic
bucket-level constraint, a Select object that queries exactly
one main table, i.e., a SELECT statement of the form:
SELECT underlyingIdColumn FROM underlyingMainTable, ...
WHERE condition
This adaptor transforms the above into:
SELECT idColumn FROM table, underlyingMainTable, ...
WHERE table.joinColumn =
underlyingMainTable.underlyingIdColumn AND
condition
The cardinality of 'underlyingMainTable' is ignored.
Exceptions thrown:
none
AUTHOR
Greg Janee
gjanee@alexandria.ucsb.edu
HISTORY
$Log: Adaptor_Relationship.py,v $
Revision 1.2 2003/10/28 22:28:06 gjanee
Removed the field-level methods to conform to the new
field translation strategy introduced in revision 1.8 of
UniversalTranslator.py.
Revision 1.1 2003/01/24 22:16:29 gjanee
Initial revision
|