Querying objects: OQL and object-relational SQL

OQL queries from the ODMG standard, persistence by reachability and SQL's object extensions in PostgreSQL: composite types, arrays, table inheritance.

  • 23 cards
  • 4 topics
  • Free

The outline, topic by topic

Each topic is weighted the way the exam weighs it.

  1. Concepts
  2. Questions
  3. Sort and link
  4. Scenarios

A few cards from the deck

  • OQL: what is it?

    Show the answer

    The ODMG standard's query language for object databases, shaped like SQL but querying classes and their references.

    select e.nom from e in Etudiants where e.promo.annee = 2 walks a class extent and follows a reference without a join.

  • The students are Ana (first-year cohort), Bo and Cy (second-year cohort) and Di (third-year cohort). What does select e.nom from e in Etudiants where e.promo.annee = 2 return?

    • Bo and Cy
    • Ana and Bo
    • Bo, Cy and Di
    • Bo only
    Show the answer

    Bo and Cy

    The path e.promo.annee follows the student's reference to their cohort and reads the year. Only students whose cohort has year 2 are returned: Bo and Cy.

  • The … standard defined a query language for object databases, ….

    Show the answer

    The ODMG standard defined a query language for object databases, OQL.

    It also set an object definition language and bindings with C++, Smalltalk and Java.

  • Path expression: what is it?

    Show the answer

    A series of names separated by dots that traverses attributes and object references from object to object.

    e.promo.annee replaces a relational database's join: you navigate from the student to their cohort then to the year.

  • personne has a primary key on id. A row whose id already exists in personne is inserted into the child table etudiant, and PostgreSQL accepts it. What is the cause?

    • The primary key checks only the table's own rows, not its children's
    • The primary key is disabled by inheritance across the hierarchy
    • The child's id is a different type from the parent's
    • INSERT never checks primary keys
    Show the answer

    The primary key checks only the table's own rows, not its children's

    Uniqueness constraints do not cross inheritance: the primary key's index covers only personne, and the child does not even inherit the constraint. An id can thus appear twice when you read the parent with its children.