Данный пример демонстрирует использование следующих конструкций языка EXPRESS в схеме, которая может быть использована в качестве образца для схем, расширенных применительно к конкретным областям применения:
- наращиваемые конструкционные типы данных;
- ограничение GENERIC_ENTITY на тип данных SELECT;
- ABSTRACT ENTITY;
- переименование атрибутов;
- SUBTYPE_CONSTRAINT.
Пример - В данном примере используются наращиваемые конструкционные типы данных.
| | | | | | |
SCHEMA my_product_management; USE FROM generic_product_management; TYPE my_additional_categories = ENUMERATION BASED_ON product_category_names WITH |
| ( document, drawing, electromechanical, mechanical, electrical, pump ); |
END_TYPE; TYPE my_additional_values = ENUMERATION BASED_ON approval_status_values WITH |
| ( approved, disapproved, pending ); |
END_TYPE; TYPE my_approvable_objects = EXTENSIBLE SELECT BASED_ON approvable_objects WITH |
| ( product, product_category, product_to_category_relationship ); |
END_TYPE; ENTITY approval_by_person_in_organization |
| SUBTYPE OF (approval); SELF\approval.approved_by: person_in_organization_relationship; |
END_ENTITY; ENTITY approval_by_person |
| SUBTYPE OF (approval); SELF\approval.approved_by :person; |
END_ENTITY; SUBTYPE_CONSTRAINT not_both FOR approval; |
| ONEOF (approval_by_person, approval_by_person_in_organization); |
END_SUBTYPE_CONSTRAINT; END_SCHEMA; SCHEMA generic_product_management; TYPE product_category_names = EXTENSIBLE ENUMERATION OF(part, tool, |
| raw_material); |
END_TYPE; TYPE approval_status_values = EXTENSIBLE ENUMERATION; END_TYPE; TYPE approvable_objects = EXTENSIBLE GENERIC_ENTITY SELECT; END_TYPE; ENTITY product; |
name : STRING; |
END_ENTITY; ENTITY product_category; | |
name : product_category_names; |
END_ENTITY; ENTITY binary_entity_relationship ABSTRACT; | |
end_one : GENERIC_ENTITY; end_two: GENERIC_ENTITY; |
END_ENTITY; ENTITY product_to_category_relationship | |
SUBTYPE OF ( binary_entity_relationship ); SELF\binary_entity_relationship.end_one RENAMED the_category : product_category; SELF\binary_entity_relationship.end_two RENAMED the_product : product; |
END_ENTITY; ENTITY approval ABSTRACT; | |
approved_by: GENERIC_ENTITY; status : approval_status_values; approved_items : SET [1 : ?] OF approvable_objects; |
END_ENTITY; ENTITY person; | |
name : STRING; |
END_ENTITY; ENTITY organization; | |
name : STRING; |
END_ENTITY; ENTITY person_in_organization_relationship | |
SUBTYPE OF (binary_entity_relationship); role_of_person : STRING; SELF\binary_entity_relationship.end_one RENAMED the_person : person; SELF\binary_entity_relationship.end_two RENAMED the_organization : organization; |
END_ENTITY; |
END_SCHEMA |