Page 1 of 1

Relvar syntax definition

Posted: Sat Aug 18, 2012 2:26 pm
by Chris Walton
I have been looking at the syntax of Rel, and am having difficulty following the definition for RelVar. It defines var_relvar as:

var_relvar ::= ( <REAL> | <BASE> ) var_type_or_init_value var_keydeflist
| <PRIVATE> var_type_or_init_value var_keydeflist
| <PUBLIC> type_ref var_keydeflist
| <VIRTUAL> expression var_keydeflistoptional

[Ignoring for the purpose of this question, the alternative parts of this definition.]
The (<REAL> | <BASE>) and var_keydeflist make sense to me, but the var_type_or_init_value part seems, if followed through to define a single type definition. What I cannot see is how the attribute list for the relvar is defined. I expected it to be this part of the definition. As it does not appear to be the definition of the attribute list, what is it defining? and where is the attribute part of relvar definition?

I am assuming that it is my lack of understanding that is the problem, as I presume the documentation is derived from the parsing system.

Thanks for any light you can throw on this.

Chris Walton

Re: Relvar syntax definition

Posted: Tue Aug 21, 2012 6:47 pm
by Dave
You wrote, "... the var_type_or_init_value part seems, if followed through to define a single type definition ..."

That is correct. A relvar can be defined by the keyword VAR, followed by a variable name, followed by REAL or BASE, followed by a relation type, followed by a key definition.

In other words, a relvar doesn't have attributes. A relvar has a relation type. The relation type has attributes.

So, for example, this is a relvar definition:

VAR myvar REAL RELATION {x CHAR, y INTEGER} KEY {x};

It consists of:

- "VAR myvar", which defines a variable of a given name;
- "REAL", which says we're going to create a persistent, relation-valued variable (i.e., a relvar) of the type following the keyword "REAL";
- A relation type - in this case, it's "RELATION {x CHAR, y INTEGER}";
- "KEY {x}" defines a key on attribute 'x' of the relation type that precedes it.

Re: Relvar syntax definition

Posted: Fri Aug 24, 2012 3:46 pm
by Chris Walton
Thanks for the explanation. I believe there is an English saying - there's none so blind as those who will not see. I could not see for looking.