Matakuliah Tahun Versi : M0174/OBJECT ORIENTED DATABASE : 2005 : 1/0 Pertemuan 14 Object Query Language (Lanjutan bagian 1) 1 Learning Outcomes Pada akhir pertemuan ini, diharapkan mahasiswa akan mampu : • Mahasiswa dapat Menghasilkan query language dalam object data model (C3) 2 Outline Materi • • • • • Selecting objects from a collection Complex test an objects Arithmetic comparisons Tests on collections String matching 3 Selecting objects from a collection • The general form of this type of OQL query is Select <variable> From <collection-object><variable> Where <restrict-predicate> 4 Selecting objects from a collection • Selecting objects from more than one collection – Union – Intersect – Except 5 Complex test an objects • The rules for evaluating a Boolean expression constructed using and, or, not, are: – An expression is evaluated form left to right – Sub expressions in brackets are evaluated first – Not are evaluated before “and” and “or”. 6 Arithmetic comparisons • • • • • • = (equal) != (not equal to) > (greater than) >= (greater than or equal to < (less than) <= (less than or equal to 7 Tests on collections • OQL Boolean expressions can test the membership of collection objects as in the object algebra. The following comparison can be made: – For all – Exist – Unique – In – Some, any, all – Set inclusion 8 String matching • String matching can be used to select objects on the basis of textual properties, such as names or decriptions • ? • * or % • Example 9 String matching • Accessing Object in a List or an Array – Accessing object in a list or an array can be done in the following way: • First, Last • Access by index • List or Array addition 10 String matching • Grouping objects • Example Select * From products p Group by colour:p.colour 11 SUMMARY • Objects are selected from a collection using the SQL-like select…from…where form of query • The form clause specifies which collection is to be searched, and the where clause specifies the condition for selecting an object 12
© Copyright 2026 Paperzz