1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
#!/bin/ash
# *********************************************************************
# Written by and copyright Carlo Strozzi <carlos@linux.it>.
#
# Note: part of this code has been freely adapted from examples
# provided in the book "Unix Relational Database Management", so
# credits are due to the original authors.
#
# depend: test for ``functional dependency'' betwen two columns.
# Copyright (C) 2001 Carlo Strozzi <carlos@linux.it>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# 2001-03-08 Beta code
# 2001-04-20 Added inline help
#
# $Id$
# *********************************************************************
if [ "$1" = -h ] || [ "$1" = --help ]
then
grep -v '^#' @DOCPATH@/depend.txt
exit 1
fi
if [ $# != 2 ]
then
echo Usage: depend column_1 column_2 >&2
exit 1
fi
[ "$TMPDIR" = "" ] && TMPDIR=/tmp
f_tmp=`mktemp $TMPDIR/nosql.XXXXXX` || exit $?
trap "rm -f $f_tmp; trap 0; exit 0" 0 1 2 3 15
column "$@" | sorttable | uniq > $f_tmp || exit $?
if [ "`wc -l < $f_tmp`" = "`column $1 -i $f_tmp | uniq | wc -l`" ]
then
echo true
exit 0
else
echo false
exit 1
fi
#
# End of program.
#
|