Newer
Older
LaTeX / relalg.sty
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% File: $Id$
%
% Defines various relational algebra symbols.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\NeedsTeXFormat{LaTeX2e}[2001/06/01]
\ProvidesPackage{relalg}[2008/02/28 Relational algebra notation]

\RequirePackage{latexsym}
\RequirePackage{graphics}
% Graphics is needed so that we can scale the size of a couple of operators.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% BASIC OPERATORS
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% select or restrict operator
\newcommand{\RelSelect}{\ensuremath{\sigma}}
\newcommand{\RelRestrict}{\RelSelect}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% project operator
\newcommand{\RelProject}{\ensuremath{\pi}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% set union operator
\newcommand{\RelUnion}{\ensuremath{\cup}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% set difference operator
\newcommand{\RelDifference}{\ensuremath{-}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% cartesian product operator
\newcommand{\RelProduct}{\ensuremath{\times}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% rename operator
\newcommand{\RelRename}{\ensuremath{\rho}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% extend operator
\newcommand{\RelExtend}{\ensuremath{\epsilon}}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ADDITIONAL OPERATORS
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% set intersection operator
\newcommand{\RelIntersection}{\ensuremath{\cap}}
\newcommand{\RelIntersect}{\RelIntersection}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% natural join operator
\newcommand{\RelNaturalJoin}{\ensuremath{\Join}}
\newcommand{\RelNatJoin}{\RelNatJoin}
\newcommand{\RelNJoin}{\RelNJoin}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% division operators
\newcommand{\RelDivide}{\ensuremath{/}}
\newcommand{\RelAltDivide}{\ensuremath{\div}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% assignment operator
\newcommand{\RelAssign}{\ensuremath{\leftarrow}}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% EXTENDED OPERATORS
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% aggregate functions
\newcommand{\RelAggregrate}[2]{\ensuremath{\mathcal{G}_{\mathbf{\mathrm{#1}}(#2)}}}
\newcommand{\RelSum}[1]{\RelAggregrate{sum}{#1}}
\newcommand{\RelAvg}[1]{\RelAggregrate{avg}{#1}}
\newcommand{\RelMin}[1]{\RelAggregrate{min}{#1}}
\newcommand{\RelMax}[1]{\RelAggregrate{max}{#1}}
\newcommand{\RelCount}[1]{\RelAggregrate{count}{#1}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% outer join operators
% Note: can't use \ensuremath in these because it screws up the spacing.
% The $ are OK though because they're used inside hboxes anyway.
\newcommand{\RelLeftOuterJoin}{\scalebox{0.5}[1]{$\sqsupset$}\mkern-2.5mu\lower0.1em\hbox{$\Join$}}
\newcommand{\RelleftOuterJoin}{\RelLeftOuterJoin}
\newcommand{\RelLOuterJoin}{\RelLeftOuterJoin}
\newcommand{\RelLeftOuter}{\RelLeftOuterJoin}
\newcommand{\RelLOJ}{\RelLeftOuterJoin}

\newcommand{\RelRightOuterJoin}{\lower0.1em\hbox{$\Join$}\mkern-2.5mu\scalebox{0.5}[1]{$\sqsubset$}}
\newcommand{\RelrightOuterJoin}{\RelRightOuterJoin}
\newcommand{\RelROuterJoin}{\RelRightOuterJoin}
\newcommand{\RelRightOuter}{\RelRightOuterJoin}
\newcommand{\RelROJ}{\RelRightOuterJoin}

\newcommand{\RelFullOuterJoin}{\scalebox{0.5}[1]{$\sqsupset$}\mkern-2.5mu\lower0.1em\hbox{$\Join$}\mkern-2.5mu\scalebox{0.5}[1]{$\sqsubset$}}
\newcommand{\RelfullOuterJoin}{\RelFullOuterJoin}
\newcommand{\RelFOuterJoin}{\RelFullOuterJoin}
\newcommand{\RelFullOuter}{\RelFullOuterJoin}
\newcommand{\RelFOJ}{\RelFullOuterJoin}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% MISCELLANEOUS
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% logical operators
% \And appears to conflict with beamer? (unconfirmed)
\newcommand{\RelLogicalAnd}{\ensuremath{\wedge}}
\newcommand{\RelLogAnd}{\RelLogicalAnd}

\newcommand{\RelLogicalOr}{\ensuremath{\vee}}
\newcommand{\RelLogOr}{\RelLogicalOr}

\newcommand{\RelLogicalNot}{\ensuremath{\neg}}
\newcommand{\RelLogNot}{\RelLogicalNot}

\endinput

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% $Log$
% Revision 1.8  2010/12/12 04:40:39  nstanger
% - Added extend operator.
%
% Revision 1.7  2010/12/12 01:25:19  nstanger
% - Normalised the logical AND/OR macros.
%
% Revision 1.6  2008/02/27 22:08:36  nstanger
% - Updated package release date.
%
% Revision 1.5  2008/02/27 22:07:34  nstanger
% - Prefixed all macro names with "Rel" to avoid namespace clashes.
%
% Revision 1.4  2005/03/08 01:25:23  nstanger
% - Updated package date.
%
% Revision 1.3  2005/03/08 01:24:51  nstanger
% - Added \leftOuterJoin, \rightOuterJoin and \fullOuterJoin to make generating
%   them from XML easier.
%
% Revision 1.2  2004/07/19 00:26:19  nstanger
% - Renamed logical operators to \LogicalXXX because of conflict with \And, possibly defined in beamer?
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%