Case Study: ODMG OQL
class city = < name: string,
places_to_visit: list (< name: string, address: string >) >
class hotel = < name: string,
rooms: set (< bed_num: int, price: int >) >
Notes:
All examples in this talk are expressed in ODMG OQL. This schema captures a city-hotel database. We may have many cities. Each city has many places to visit and many hotels. Each hotel has many rooms. A city is an instance of the city class while a hotel is an instance of the hotel class. A bag is a set with duplicates. The hotel in the bag(hotel) is a reference to a hotel object. The variable cities is the extent of the class city. It is the set of all cities.
The OQL query retrieves all the hotels in Arlington that are also interesting places to visit. This query is not a relational query for two reasons: First, variables h and p range over collections whose values depend on the value of c, which is a city. Second, we have multiple collection types: c ranges over a set, h over a bag, and p over a list.