Define a schema using ODL

Top | Next

We want to modelize a very simple university environment:

  • A course is caracterized by a title and a description
  • A student is caracterized by a firstname, a lastname and a registration year
  • A teacher is caracterized by a firstname and a lastname
  • A teacher is in charge of one or several courses
  • A student is registered to one or several courses

The following schema implements the previous model by introducing:

  • The given attributes: firstname, lastname, begin_year, title, description
  • A superclass Person which factorizes the firstname and lastname attributes of students and teachers
  • Relationships between:
    • Student and registered courses (called “registered to”)
    • Teacher and in charge courses (called “in charge”)

Here is the Object Definition Language (ODL) implementation of the previous model:

class Person {
  attribute string firstname;
  attribute string lastname;
};

class Student extends Person {
  attribute short begin_year;
  relationship set<Course *> courses inverse students;
};

class Course {
  attribute string title;
  attribute string description;
  relationship set<Student *> students inverse courses;
  relationship Teacher *teacher inverse courses;
};

class Teacher extends Person {
  relationship set<Course *> courses inverse teacher;
};

View the ODL file.

A few comments:

  • The inheritance between the classes Student and Person and between Teacher and Person is indicated by the extends keyword.
  • The set<Course *> courses attribute in the Student class and the set<Student *> students attribute in
    the Course class denote the relationship between the Student and its registered courses
  • The set<Course *> courses attribute in the Teacher class and the Teacher *teacher attribute in the
    Course class denotes the relationship between the Teacher and its in charge Courses
  • The inverse directives on the relationship attributes are there to indicate to EyeDB to maintain the referential integrity of the relationships

To enter this schema in a database, we must use the eyedbodl tool which checks the syntax and semantics of the schema and in case of succes submit the given schema to the given database.

Top | Next