Relation valued

This forum is for any questions about the language Tutorial D or the Rel implementation of it.
Post Reply
ofigue
Posts: 1
Joined: Tue Oct 26, 2010 7:36 pm

Relation valued

Post by ofigue »

Hi, I created a relvar with a relation-valued attribute an I inserted some tuples. can you tell me how to query relation-valued values?
Thanks
Dave
Site Admin
Posts: 372
Joined: Sun Nov 27, 2005 7:19 pm

Re: Relation valued

Post by Dave »

Given, for example, this:

Code: Select all

VAR aVar REAL RELATION {x INTEGER, y RELATION {a INTEGER, b INTEGER}} KEY {x};

INSERT aVar RELATION {
  TUPLE {x 1, y RELATION {TUPLE {a 45, b 13}, TUPLE {a 33, b 4}}},
  TUPLE {x 2, y RELATION {TUPLE {a 7, b 28}}},
  TUPLE {x 3, y RELATION {TUPLE {a 3, b -3}, TUPLE {a 34, b 12}, TUPLE {a -3, b 45}}}
};
You can do queries like this:

Code: Select all

aVar WHERE x > 1 AND TUPLE {a 3, b -3} IN y
Or this:

Code: Select all

aVar WHERE x > 1 AND SUM(y, a) > 2
Etc.
Post Reply