Ungrouping complex relvars

This forum is for any questions about the language Tutorial D or the Rel implementation of it.
Post Reply
Chris Walton
Posts: 76
Joined: Sat Aug 18, 2012 2:13 pm

Ungrouping complex relvars

Post by Chris Walton » Fri Dec 13, 2013 5:59 pm

While I know there may be issues with relation valued attributes, and their use often does not constitute the best principles of design; it is convenient to make use of this relvar "Entity.structures" at a specific point in my development:

Code: Select all

// Input and response
Entity.structures
RELATION {name ID, structures RELATION {name ID, nodes RELATION {node nodeID}}} {}
This structure is complicated, and its original definition is:

Code: Select all

VAR Domain BASE RELATION { domain CHARACTER, name CHARACTER } KEY { domain } KEY { name };
TYPE ID UNION POSSREP { domain CHARACTER, name CHARACTER CONSTRAINT TUPLE { domain domain } IN Domain { domain } };
VAR Node_type BASE RELATION { name ID } KEY { name };
TYPE node_type POSSREP { name ID CONSTRAINT TUPLE { name name } IN Node_type { name } };
TYPE nodeID POSSREP { name ID, s# INTEGER, d# INTEGER, n_type node_type };
VAR ELH BASE RELATION { name ID, nodes RELATION { node nodeID } } KEY { name };
VAR Entity.structures BASE RELATION { name ID, structures RELATION SAME_HEADING_AS ( ELH ) } KEY { name };
When attempting to flatten the components of this relvar, using UNGROUP, I get the following error:

Code: Select all

// Input and response
Entity.structures UNGROUP ( structures )
ERROR: Relation-valued attribute 'structures' shares attributes with RELATION {name ID, structures RELATION {name ID, nodes RELATION {node nodeID}}}
Line 1, column 1 near 'Entity.structures'
How do I flatten the subordinate relations (structures and nodes)?

Dave
Site Admin
Posts: 364
Joined: Sun Nov 27, 2005 7:19 pm

Re: Ungrouping complex relvars

Post by Dave » Sat Dec 14, 2013 9:18 pm

You have to make sure your relation-valued attribute does not share attribute names with the relation that contains it. You can use RENAME to address this.

Post Reply