Page 1 of 1

Yet another syntax query

Posted: Fri Nov 22, 2013 8:53 pm
by Chris Walton
I have defined many lookup relvars which I use in defining types. For example:

Code: Select all

// Utillity type used throughout
TYPE ID1 POSSREP { VALUE CHARACTER CONSTRAINT LENGTH ( VALUE ) <= 36 };

// Lookup relvar
VAR lookup BASE RELATION { P ID1 } KEY { P };
// Lookup constrained type
TYPE LU IS { ID1 CONSTRAINT TUPLE { P ID1 } IN lookup { P } POSSREP { X = THE_VALUE ( ID1 ) } };
I cannot extend this to a data type that has multiple attributes, and is not a subtype, without having problems.

What I am trying to do is:

Code: Select all

// Define a relvar that partitions other definitions
VAR DU BASE RELATION { d1 ID, n1 ID } KEY { d1 };
// Define a type that is going to be used throughout the system, which appears in the above relvar
TYPE ident POSSREP { domain ID1, name ID1 CONSTRAINT TUPLE { domain ID1 } IN DU { d1 } };
This gives the error 'ID1' has not been defined. Other approaches give different errors.

What syntax is needed to achieve what I am trying to do?

Re: Yet another syntax query

Posted: Mon Nov 25, 2013 3:32 pm
by Dave
Can you give me an example of what you're trying with a data type that has multiple attributes and is not a subtype? I'm not sure I'm following what you're trying to do.

Re: Yet another syntax query

Posted: Mon Nov 25, 2013 4:50 pm
by Chris Walton
My second example shows what I am trying to do. A major component of my development is "domain" - an self contained area of interest in system development - eg application domain. It has nothing to do with the relational model use of the term domain. Every other item I define belongs to one and only one domain. An abbreviated definition of domain is:

Code: Select all

VAR Domain BASE RELATION { domain ID,  name ID } KEY { domain, name };
I am trying to define a type:

Code: Select all

TYPE ident POSSREP { domain ID, name ID CONSTRAINT TUPLE { domain ID } IN Domain { domain } };
It is a fundamental part of this definition that the domain portion of it must appear as a tuple in relvar Domain - ie that eg a specified relvar, type, constraint, operator belongs to a predefined domain. This type will be used as a identifier type and in keys, wherever a new item is defined for eg:

Code: Select all

VAR Test_example BASE RELATION { name ident, other_attributes CHARACTER } { KEY name };

Re: Yet another syntax query

Posted: Wed Nov 27, 2013 1:25 pm
by Dave
Still not sure I'm quite getting it. Do you mean something like this?

Code: Select all

TYPE ID POSSREP {x CHAR};

VAR Domain REAL RELATION {domain ID, name ID} KEY {domain, name};

TYPE ident POSSREP {domain ID, name ID  CONSTRAINT TUPLE {domain domain, name name} IN Domain};

Re: Yet another syntax query

Posted: Thu Nov 28, 2013 1:35 am
by Chris Walton
Your suggestion is close to what I was trying to do. In fact my code will be based on:

Code: Select all

TYPE ID POSSREP {x CHAR};
VAR Domain BASE RELATION { domain ID, predicate CHARACTER } KEY { domain };
TYPE ident POSSREP {domain ID, name ID CONSTRAINT TUPLE { domain domain } IN Domain { domain } };
VAR Event BASE RELATION { name ident } KEY { name };
I was having problems defining the second type above.

While I appreciate that Rel is the implementation of a clear, simple model; it is obviously no match for the brand of simple mindedness I am bringing to it. Many thanks for the guidance.