Re: Translating constraints to RM Terms

From: Jonathan Leffler <jleffler_at_earthlink.net>
Date: Mon, 06 Jun 2005 04:36:52 GMT
Message-ID: <EpQoe.2623$W77.822_at_newsread3.news.pas.earthlink.net>


Kenneth Downs wrote:
> I'm wondering if some RM theorist might express something for me.
>
> Consider table X with columns A and B. There is a constraint that A must be
> less than B. While we discuss such constraints every day, I realize I do
> not know how to express such constraints in relational terms.
>
> For instance, A is actually a domain, as is B, but the constraint A < B must
> in fact be part of the very definition of the domain A, and here we are
> defining one domain in terms of another.

A is a 'column' or attribute; it is defined on a domain, but (except in Codd's 1970 paper), columns are different from domains. A domain is the data type.

If A and B are attributes that must be compared (constrained) as you suggest, they would normally be the same type (defined on the same domain).

Don't forget that a domain defines the complete set of values that can be stored in an attribute defined on that domain. If you have a domain of negative integers - call it A - and a domain of positive integers - call it B - then you can infer that all values in domain A are smaller than all values in domain B.

So, I reject the contention that 'A < B' must be part of the definition of domain A, and I'm far from convinced that we are defining one domain in terms of another.

> I realized I have not seen this
> disccussed in the year or so I have been a regular here. Is defining one
> domain in terms of another allowed and considered trivial, no big deal? Is
> it actually not allowed and this is some SQL alteration of true RM?

It depends in part to whom you speak. To compare two values, there must be a suitable comparator. The simplest cases expect to compare two values of the same type. In practice, SQL DBMS usually provide numerous implicit conversions such that you can 'compare' two values of different types - because the DBMS actually converts one or both values so that they can be compared.

-- 
Jonathan Leffler                   #include <disclaimer.h>
Email: jleffler_at_earthlink.net, jleffler_at_us.ibm.com
Guardian of DBD::Informix v2005.01 -- http://dbi.perl.org/
Received on Mon Jun 06 2005 - 06:36:52 CEST

Original text of this message