Page 1 of 1

Ungrouping complex relvars

Posted: Fri Dec 13, 2013 5:59 pm
by Chris Walton
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)?

Re: Ungrouping complex relvars

Posted: Sat Dec 14, 2013 9:18 pm
by Dave
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.