-- Example EXPRESS file in HTML-format

SCHEMA example; 

TYPE date = ARRAY[1:3] OF INTEGER;
END_TYPE;

TYPE hair_type = ENUMERATION OF (
  blonde,
  brown,
  black,
  red,
  white,
  bald );
END_TYPE;

ENTITY person
  SUPERTYPE OF ( ONEOF ( male, female ) );
  first_name:	STRING;
  last_name:	STRING;
  nickname:	OPTIONAL STRING;
  birth_date:	date;
  children:	SET[0:?] OF person;
  hair:		hair_type;
DERIVE
  age:		INTEGER := years( birth_date );
INVERSE
  eltern:	SET[0:2] OF person FOR children;
END_ENTITY;

ENTITY female
  SUBTYPE OF ( person );
  husband:	OPTIONAL male;
  maiden_name:	OPTIONAL STRING;
WHERE
  w1: ( EXISTS ( maiden_name ) AND
	EXISTS ( husband ) ) XOR 
	NOT EXISTS ( maiden_name );
END_ENTITY;

ENTITY male
  SUBTYPE OF ( person );
  wife:	OPTIONAL female;
END_ENTITY;

RULE married FOR ( female, male);
  (* checks pairwise relationship between spouses *)
WHERE
  r1:	SIZEOF(
	QUERY ( tf <* female | EXISTS( tf.husband ) AND
	( tf.husband.wife :<>: tf ) ) ) = 0;
  r2:	SIZEOF(
	QUERY ( tm <* male | EXISTS( tm.wife ) AND
	( tm.wife.husband :<>: tm ) ) ) = 0;
END_RULE;

FUNCTION years ( past : date ): INTEGER;
  (* This function calculates the number of years
  between the past date and the current date *)
END_FUNCTION;

END_SCHEMA;