Matakuliah Tahun Versi : M0174/OBJECT ORIENTED DATABASE : 2005 : 1/0 Pertemuan 15 Object Query Language (Lanjutan bagian 2) 1 Learning Outcomes Pada akhir pertemuan ini, diharapkan mahasiswa akan mampu : • Mahasiswa dapat Menghasilkan query language dalam object data model (C3) 2 Outline Materi • Processing mutable objects • Processing a collection of many types of object • Computations on arithmetic and string literal 3 Processing mutable objects • Mutable objects are manipulated by executing the operations defined for the respective object types • Example 4 Processing a collection of many types of object • An added complexity can occur when executing operations on a collection object which contain objects of many types. • In such situations, there may be multiple implementations of the operation. It is therefore necessary to determine, for each object, which implementation to use 5 Processing a collection of many types of object • OQL supports two different ways of resolving this problem: – Late binding: this mechanism allow general query to be specialized for each object when query is execute. – Class indicator: class indicator override late binding to ensure that only objects of a specified type are accessed. 6 Processing a collection of many types of object • Late binding is a useful mechanism, since it allows operations to be invoked at the most general level but then executed at the most specific. • This simplifies application programs, since they don’t have to take into account difference between subtypes 7 Processing a collection of many types of object • Late binding also insulates applications program from many change to the object database. • Sometime we may wish to override late binding and ensure that we process only specific types of object within a collection. This done by Class Indicator, for example: Select ((RetailCustomer) c).discount from Customer c 8 Computations on arithmetic and string literal • In addition to the user-defined operations on objects, OQL includes a number of built in operations upon literal • These can be used to construct queries which perform arithmetic computations on numeric • Example 9 Computations on arithmetic and string literal <query> ::= <query> + <query> | <query> - <query> | <query> / <query> | <query> * <query> | - <query> | <query> mod <query> | abs <query> 10 SUMMARY • Mutable objects can be processed by executing instance operations • These are accessed using paths • When this is done, there is a danger of side-effects 11 SUMMARY • When collection contains many types of object, the correct implementation of an operation is chosen using late binding • This can be overridden with class indicator 12