Ampersand icon indicating copy to clipboard operation
Ampersand copied to clipboard

Mapping named things: concepts, relations, rules, interfaces, etc.

Open stefjoosten opened this issue 1 year ago • 3 comments

Problem

As an Ampersand user, I may want to reuse an existing dataset for many reasons. For example, I might want to add new functionality, I may want to tap into an existing dataset, I might want to migrate data into a new application, or I may want to verify the consistency of data across the borders of multiple datasets. In all cases, I want to read another database while renaming some of the items. This issue assumes that I do NOT want to change its schema because it is being used by others, who must continue what they are doing. Yet, I DO want to change its schema because I need to rename certain concepts, relations, rules, and other named objects.

The question is: can I apply a name mapping to an existing dataset while retaining the existing schema?

Desired Solution

We can fetch the mapping itself from an Ampersand script, by extending the INCLUDE statement with a mapping. For that, we need extra syntax in the Ampersand language. The starting point is an existing system with Ampersand script 1, Schema 1, a dataset, and API1 to keep disclosing that dataset in production. afbeelding Since we don't want to alter API-1, let us put a second one API-2 to access the same dataset but with the new names specified in the mapping. In this way, existing users can continue to use API-1 because it keeps working unaffected by the addition of API-2.

Example

Here is Ampersand script 1:

CONTEXT Script1
RELATION r[A*B]

INTERFACE Overview : "_SESSION"[SESSION] BOX
   [ As : V[SESSION*A] ]
ENDCONTEXT

Here is Ampersand script 2:

CONTEXT Script2
INCLUDE "Script1.adl"
   { CONCEPT A --> X
   , INTERFACE Overview [ As --> Xs ]
   , RELATION r[A*B] --> s
   }

RELATION t[A*B]
ENDCONTEXT

When the user runs Ampersand script 2, she sees an application with the following spec:

CONTEXT Script2

RELATION s[X*B]

INTERFACE Overview : "_SESSION"[SESSION] BOX
   [ Xs : V[SESSION*X ]

RELATION t[A*B]
ENDCONTEXT

Besides, she can run Ampersand script 1 in parallel. She sees that changes in the relation r[A*B] of Ampersand script 1 will appear as changes in relation s[X*B] of Ampersand script 1.

stefjoosten avatar Jul 23 '23 07:07 stefjoosten