Domains, Domains, My Kingdom for a Domain!

by Jonathan Gennick

Related link: http://five.pairlist.net/pipermail/oracle-article/2004/000015.html



Domains, Domains, My Kingdom for a Domain!


While editing Chris Date's upcoming book on the relational model, I came across
a discussion on domains, which, among other things, are intended to prevent
the sort of error that you see in the statement below:


SELECT S.SNO, S.SNAME, S.CITY, P.PNO, P.PNAME
FROM SUPPLIER S, PART P, SUPPLIER_PART SP
WHERE S.SNO = SP.SNO
AND P.PNO = SP.SNO;

Domains are a feature of the relational model not widely implemented by vendors.
Actually, I'm not sure whether any vendor even attempts to implement them. It
occurred to me though, that domains are essentially user-defined datatypes,
and that it might be interesting to apply Oracle's user-defined datatype features
to the problem of properly distinguishing between simple datatypes such as supplier
and part numbers. Oracle's user-defined datatypes were conceived of as object
types, so using them as the basis for simple, numeric columns was a bit of a
stretch. I ran through a little experiment, and, if you're interested, you can
read about how it went in my article titled: Domains,
Domains, My Kingdom for a Domain!