Simple supertype, complex subtype
Posted: Sat Aug 24, 2013 4:42 pm
If it is possible to express the following situation in Rel, could you suggest the syntax to achieve it?
These have been defined:
TYPE identifier
POSSREP { VALUE CHAR CONSTRAINT
LENGTH ( VALUE ) <= 36 } ;
VAR BDT BASE RELATION
{ name identifier }
KEY { name } ;
TYPE base_data_type IS
{ identifier
CONSTRAINT TUPLE { name identifier } IN BDT { name }
POSSREP { X = THE_VALUE ( identifier ) } } ;
and a number of subtypes of base_data_type have been defined - all of the form:
VAR Arbitrary BASE RELATION
{ name identifier }
KEY { name } ;
TYPE arbitrary IS
{ base_data_type
CONSTRAINT TUPLE { name identifier ( base_data_type ) } IN Arbitrary { name }
POSSREP { Y = THE_X ( base_data_type ) } } ;
base_data_type is a very simple data type - the only data it has is its name.
I now want to define a further data type, also a subtype of base_data_type, but which is more complex; and all the complexity resides in the subtype. If it were not a subtype it would be defined as:
TYPE timestamp
POSSREP ISO {
YY N99,
MM N12 } ;
where:
TYPE N99
POSSREP { VALUE INTEGER CONSTRAINT
VALUE >= 00 AND VALUE <= 99 } ;TYPE N31
POSSREP { VALUE INTEGER CONSTRAINT
VALUE >= 01 AND VALUE <= 31 } ;
All my attempts at defining this as a subtype in a similar way to the other subtypes [with a corresponding relvar defined:
VAR Timestamp BASE RELATION
{ name identifier,
CC N99,
MM N12 }
KEY { name };]
lead to messages like "N99 is not a supertype of timestamp".
What is the appropriate syntax for this definition?
These have been defined:
TYPE identifier
POSSREP { VALUE CHAR CONSTRAINT
LENGTH ( VALUE ) <= 36 } ;
VAR BDT BASE RELATION
{ name identifier }
KEY { name } ;
TYPE base_data_type IS
{ identifier
CONSTRAINT TUPLE { name identifier } IN BDT { name }
POSSREP { X = THE_VALUE ( identifier ) } } ;
and a number of subtypes of base_data_type have been defined - all of the form:
VAR Arbitrary BASE RELATION
{ name identifier }
KEY { name } ;
TYPE arbitrary IS
{ base_data_type
CONSTRAINT TUPLE { name identifier ( base_data_type ) } IN Arbitrary { name }
POSSREP { Y = THE_X ( base_data_type ) } } ;
base_data_type is a very simple data type - the only data it has is its name.
I now want to define a further data type, also a subtype of base_data_type, but which is more complex; and all the complexity resides in the subtype. If it were not a subtype it would be defined as:
TYPE timestamp
POSSREP ISO {
YY N99,
MM N12 } ;
where:
TYPE N99
POSSREP { VALUE INTEGER CONSTRAINT
VALUE >= 00 AND VALUE <= 99 } ;TYPE N31
POSSREP { VALUE INTEGER CONSTRAINT
VALUE >= 01 AND VALUE <= 31 } ;
All my attempts at defining this as a subtype in a similar way to the other subtypes [with a corresponding relvar defined:
VAR Timestamp BASE RELATION
{ name identifier,
CC N99,
MM N12 }
KEY { name };]
lead to messages like "N99 is not a supertype of timestamp".
What is the appropriate syntax for this definition?