Re: Normalisation

From: Jon Heggland <heggland_at_idi.ntnu.no>
Date: Wed, 6 Jul 2005 10:32:38 +0200
Message-ID: <MPG.1d35b08b3efd14a69896e5_at_news.ntnu.no>


In article <PwBye.138032$Nn7.7012386_at_phobos.telenet-ops.be>, jan.hidders_at_REMOVETHIS.pandora.be says...
> > Does it matter whether my unnest_string is system defined (by the DBMS)
> > or user-defined?
>
> Yes.

Are you serious? If unnest_string is system defined, relations with string attributes are in 1NF, but if the exact same operator is user defined, they are not? Why on earth would you want to make such a distinction?

> Note btw. that if user-defined functions are restricted to the
> domains (their input and output types are only domains) then you cannot
> define such an operation as a user-defined function.

Let me try to define such an operator.

unnest_string takes a relation IN and an attribute name A as arguments, returns a relation OUT. The type of attribute A in IN is character string.

First, I derive an array of tuples from IN, in order to iterate over it. Alternatively, I use a cursor; the point is to access tuples one at a time.

For each tuple T, I look at the string value S of attribute A.

For each character C in S (I use length and substring operators here), I insert a tuple into OUT (if it is not already there), consisting of the tuple T without A, but with a new attribute B, the value of which is C for the new tuple in question.

Is there anything wrong with this?

-- 
Jon
Received on Wed Jul 06 2005 - 10:32:38 CEST

Original text of this message