# Re: Modeling question...

From: David BL <davidbl_at_iinet.net.au>
Date: Fri, 24 Oct 2008 03:13:21 -0700 (PDT)

On Oct 24, 4:16 pm, "Walter Mitty" <wami..._at_verizon.net> wrote:
> "David BL" <davi..._at_iinet.net.au> wrote in message
>
>
> >Ok, I’ll bite…
> >No doubt any data can be made to “fit” into the relational model.
> >The more important question is whether it happens /naturally/. The
>
> I don't understand the word "naturally" in this context. Isn't all modeling
> artificial, rather than natural?

I'm suggesting that in certain situations the RM is cumbersome, making it inappropriate or inapplicable. This is specifically with regard to /recursive data types/.

For example, recursive data types are appropriate for representing wffs in most formal languages. They are also relevant in compound documents. Eg

struct Chapter
{

String title;
Vector<Paragraph> paragraphs;
Vector<Chapter> subchapters;
};

There are two ways that the RM can be used to represent recursive data types:

1. Using recursive RVAs; or
2. By introducing abstract identifiers for all the nodes, and appropriate integrity constraints

I find the first quite reasonable, but I'm suspicious of actually calling such an approach "relational".

Using Prolog notation, consider the following relations which allow for representing an expression such as (x+1)*3:

var(N,S) :- node N is a variable named S     number(N,I) :- node N is a number with value I     add(N,N1,N2) :- node N is the addition of nodes N1,N2     mult(N,N1,N2) :- node N is the product of nodes N1,N2

Define a view called nodes(N) which is a union of projections as follows:

```    nodes(N) :- var(N,_).
nodes(N) :- number(N,_).
nodes(N) :- mult(N,_,_).

```

The following are the integrity constraints (each query must be empty):

var(N,S1), var(N,S2), S1 <> S2?

```    add(N,_,N1), add(N,_,N2), N1 <> N2?
mult(N,N1,_), mult(N,N2,_), N1 <> N2?
mult(N,_,N1), mult(N,_,N2), N1 <> N2?
var(N,_),  number(N,_)?
var(N,_),  mult(N,_,_)?
```

```    add(N,_,_), mult(N,_,_)?