The abstract relational schema that results from mapping the OPM schema is kept in a a file that is assigned a name consisting of the name of the file containing the input OPM schema, followed by ``.REL''.
The BNF syntax for abstract relational schemas is given below.
<relational schema specification> ::= <number of relations>
<db name> <relational schema>
| <db name> <relational schema>
;
<db name> ::= DATABASE <database name>
| <null>
;
<relational schema> ::= <relation or user specified domain>
| <relational schema> <relation or user specified domain>
;
<relation or user specified domain> ::= <relation>
| <view>
| <user specified domain>
;
<relation> ::= <rel keyword> <relation name>
( <attributes>
<primary-key>
<alternate-keys>
<foreign-keys>
<segment>
<indexes or null> )
;
<rel keyword> ::= RELATION
| DOMAIN RELATION
;
<attributes> ::= <attribute>
| <attributes> , <attribute>
;
<attribute> ::= <attribute name> <attribute domain> <null rule>
<attribute default>
;
<attribute domain> ::= <system domain>
| <user specified domain name>
;
<system domain> ::= _id
| <data type>
| <data type> ( <integer> )
| <data type> ( <integer> , <integer> )
;
<user specified domain> ::= DOMAIN <user specified domain name> <system domain>
<code type>
<values> <default> <in relation or with rule>
;
<code type> ::= <system domain>
| <null>
;
<values> ::= VALUES: <value list>
| <null>
;
<default> ::= DEFAULT: <default value>
| <null>
;
<in relation or with rule> ::= IN RELATION <relation name>
| WITH <rule name>
;
<value-list> ::= <enumerated values>
| <ranges>
;
<enumerated values> ::= <value_code_desc>
| <enumerated values> , <value_code_desc>
;
<value_code_desc> ::= <value>
| ( <value> , <code> )
| ( <value> , <code> , <value description> )
;
<value description> ::= <text>
;
<ranges> ::= <range>
| <ranges> , <range>
;
<range> ::= <number> - <number>
;
<null rule> ::= NO NULLS
| NULLS ALLOWED
| <null>
;
<attribute default> ::= DEFAULT <real>
| DEFAULT <text>
| <null>
;
<primary-key> ::= PRIMARY KEY ( <attribute list> )
;
<alternate-keys> ::= <alternate-key list>
| <null>
;
<alternate-key list> ::= <alternate-key>
| <alternate-key list> <alternate-key>
;
<alternate-key> ::= ALTERNATE KEY ( <integer> ) ( <attribute list> )
;
<foreign-keys> ::= <foreign-key list>
| <null>
;
<foreign-key list> ::= <foreign-key>
| <foreign-key list> <foreign-key>
;
<foreign-key> ::= FOREIGN KEY ( <attribute list> )
REFERENCES <referenced relations> delete-rule
<mutual exclusions>
;
<referenced relations> ::= <relation name>
| <referenced relations> OR <relation name>
;
<mutual exclusions> ::= <null>
| NOT IN <excluded relations>
;
<excluded relations> ::= <relation name>
| <excluded relations> AND <relation name>
;
<attribute list> ::= <attribute name>
| <attribute list> , <attribute name>
;
<delete-rule> ::= RESTRICTED | CASCADE | NULLIFY
;
<segment> ::= SEGMENT <segment name>
| <null>
;
<indexes or null> ::= <indexes>
| <null>
;
<indexes> ::= <index>
| <indexes> <index>
;
<index> ::= INDEX <text>
;
<view> ::= VIEW <view name>
DEFINITION : <SQL view definition> ;
;
<attribute name> ::= /* character string */
;
<relation name> ::= /* character string */
;
<view name> ::= /* character string */
;
<rule name> ::= /* character string */
;
<user specified domain name> ::= /* character string */
;
<data type> ::= /* character string */
;
<segment name> ::= /* character string */
;
<integer> ::= /* positive integer */
;
<real> ::= /* real number */
;
<number of relations> ::= <integer>
;
<text> ::= /* quoted text */
;
<SQL view definition> ::= /* SQL view definition statement */
;
<value> ::= /* a numeric value or an alphanumeric value within quotes */
;
For example, when the translator takes as input the OPM schema shown in section 3, it generates the following abstract relational schema:
DOMAIN Rank varchar(255)
VALUES:
"Professor",
"Associate Professor",
"Assistant Professor"
WITH Rank_rule
DOMAIN Salary int
VALUES:
"30000"-"150000"
WITH Salary_rule
DOMAIN RELATION CLASSES (
_cid int NO NULLS,
_dbid int NULLS ALLOWED,
_alias varchar(80) NULLS ALLOWED,
_classDescr varchar(255) NULLS ALLOWED,
_className varchar(32) NO NULLS,
_type varchar(20) NO NULLS
PRIMARY KEY (_cid)
FOREIGN KEY (_dbid)
REFERENCES DATABASES RESTRICTED
RELATION_VALUES:
(0, NULL, NULL, "OBJECTS", "OBJECTS", "Object"),
(2, NULL, NULL, NULL, "PERSON", "Object"),
(3, NULL, NULL, NULL, "FACULTY", "Object"),
(8, NULL, NULL, NULL, "PROFESSOR", "Derived Subclass"),
(4, NULL, NULL, NULL, "STUDENT", "Object"),
(5, NULL, NULL, NULL, "COURSE", "Object"),
(6, NULL, NULL, NULL, "DEPARTMENT", "Object"),
(7, 0, "Publication", "References in PUBLICATIONS database", "REFERENCE", "Foreign")
)
RELATION COURSE (
_defaultVersion int NULLS ALLOWED,
_nextVersion int NULLS ALLOWED,
_oid _id NO NULLS,
courseNumber char(10) NO NULLS,
name varchar(80) NULLS ALLOWED
PRIMARY KEY (_oid)
ALTERNATE KEY (1) (courseNumber)
FOREIGN KEY (_oid)
REFERENCES OBJECTS CASCADE
FOREIGN KEY (_oid, _defaultVersion)
REFERENCES _vCOURSE RESTRICTED
INDEX "create nonclustered index defind_COURSE on COURSE (_oid)"
)
RELATION COURSE_references (
_aid _id_i NO NULLS,
_oid _id NO NULLS,
_version int NO NULLS,
references _id NULLS ALLOWED
PRIMARY KEY (_aid)
FOREIGN KEY (_oid, _version)
REFERENCES _vCOURSE CASCADE
FOREIGN KEY (references)
REFERENCES REFERENCE RESTRICTED
INDEX "create nonclustered index defind_COURSE_references on COURSE_references (_oid, _version)"
)
DOMAIN RELATION DATABASES (
_dbid int NO NULLS,
_dbDescr varchar(255) NULLS ALLOWED,
_dbName varchar(80) NO NULLS
PRIMARY KEY (_dbid)
RELATION_VALUES:
(0, "database for course references", "PUBLICATIONS")
)
RELATION DEPARTMENT (
_oid _id NO NULLS,
name int NO NULLS
PRIMARY KEY (_oid)
ALTERNATE KEY (1) (name)
FOREIGN KEY (_oid)
REFERENCES OBJECTS CASCADE
FOREIGN KEY (name)
REFERENCES DepartmentNames RESTRICTED
INDEX "create nonclustered index defind_DEPARTMENT on DEPARTMENT (_oid)"
)
DOMAIN RELATION DepartmentNames (
_code int NO NULLS,
_defn varchar(255) NULLS ALLOWED,
_value varchar(255) NO NULLS
PRIMARY KEY (_code)
RELATION_VALUES:
(1, NULL, "Computer Science"),
(2, NULL, "Engineering")
)
RELATION FACULTY (
_defaultVersion int NULLS ALLOWED,
_nextVersion int NULLS ALLOWED,
_oid _id NO NULLS,
department _id NULLS ALLOWED,
rank Rank NULLS ALLOWED
PRIMARY KEY (_oid)
FOREIGN KEY (_oid)
REFERENCES PERSON CASCADE
FOREIGN KEY (_oid, _defaultVersion)
REFERENCES _vFACULTY RESTRICTED
FOREIGN KEY (department)
REFERENCES DEPARTMENT RESTRICTED
INDEX "create nonclustered index defind_FACULTY on FACULTY (_oid)"
NOT_IN: STUDENT
)
RELATION OBJECTS (
_oid _id_i NO NULLS
PRIMARY KEY (_oid)
)
RELATION PERSON (
_oid _id NO NULLS,
name varchar(50) NULLS ALLOWED,
ssn int NO NULLS
PRIMARY KEY (_oid)
ALTERNATE KEY (1) (ssn)
FOREIGN KEY (_oid)
REFERENCES OBJECTS CASCADE
INDEX "create nonclustered index defind_PERSON on PERSON (_oid)"
)
RELATION REFERENCE (
_foreignOid varchar(255) NO NULLS,
_oid _id NO NULLS
PRIMARY KEY (_oid)
ALTERNATE KEY (1) (_foreignOid)
FOREIGN KEY (_oid)
REFERENCES OBJECTS CASCADE
INDEX "create nonclustered index defind_REFERENCE on REFERENCE (_oid)"
)
DOMAIN RELATION SCLASSES (
_class int NO NULLS,
_subclass int NULLS ALLOWED
FOREIGN KEY (_class)
REFERENCES CLASSES RESTRICTED
FOREIGN KEY (_subclass)
REFERENCES CLASSES RESTRICTED
RELATION_VALUES:
(0, 2),
(2, 3),
(2, 4),
(0, 5),
(0, 6),
(0, 7)
)
RELATION STUDENT (
_defaultVersion int NULLS ALLOWED,
_nextVersion int NULLS ALLOWED,
_oid _id NO NULLS
PRIMARY KEY (_oid)
FOREIGN KEY (_oid)
REFERENCES PERSON CASCADE
FOREIGN KEY (_oid, _defaultVersion)
REFERENCES _vSTUDENT RESTRICTED
INDEX "create nonclustered index defind_STUDENT on STUDENT (_oid)"
NOT_IN: FACULTY
)
RELATION STUDENT_attends (
_aid _id_i NO NULLS,
_oid _id NO NULLS,
_vcourse int NULLS ALLOWED,
_version int NO NULLS,
course _id NULLS ALLOWED,
inDepartment _id NULLS ALLOWED
PRIMARY KEY (_aid)
FOREIGN KEY (_oid, _version)
REFERENCES _vSTUDENT CASCADE
FOREIGN KEY (course, _vcourse)
REFERENCES _vCOURSE RESTRICTED
FOREIGN KEY (inDepartment)
REFERENCES DEPARTMENT RESTRICTED
INDEX "create nonclustered index defind_STUDENT_attends on STUDENT_attends (_oid, _version)"
)
RELATION _vCOURSE (
_deleteDate datetime NULLS ALLOWED,
_fromDate datetime NO NULLS,
_oid _id NO NULLS,
_preVersion int NULLS ALLOWED,
_version int NO NULLS
PRIMARY KEY (_oid, _version)
FOREIGN KEY (_oid)
REFERENCES COURSE CASCADE
INDEX "create nonclustered index defind__vCOURSE on _vCOURSE (_oid, _version)"
)
RELATION _vFACULTY (
_deleteDate datetime NULLS ALLOWED,
_fromDate datetime NO NULLS,
_oid _id NO NULLS,
_preVersion int NULLS ALLOWED,
_version int NO NULLS,
salary Salary NULLS ALLOWED
PRIMARY KEY (_oid, _version)
FOREIGN KEY (_oid)
REFERENCES FACULTY CASCADE
INDEX "create nonclustered index defind__vFACULTY on _vFACULTY (_oid, _version)"
)
RELATION _vSTUDENT (
_deleteDate datetime NULLS ALLOWED,
_fromDate datetime NO NULLS,
_oid _id NO NULLS,
_preVersion int NULLS ALLOWED,
_version int NO NULLS
PRIMARY KEY (_oid, _version)
FOREIGN KEY (_oid)
REFERENCES STUDENT CASCADE
INDEX "create nonclustered index defind__vSTUDENT on _vSTUDENT (_oid, _version)"
)
VIEW PROFESSOR
DEFINITION: create view PROFESSOR ( _oid )
as select _oid from FACULTY
where rank = "Professor";