object query language oql
Download
Skip this Video
Download Presentation
Object Query Language ( OQL )

Loading in 2 Seconds...

play fullscreen
1 / 18

Object Query Language ( OQL ) - PowerPoint PPT Presentation


  • 84 Views
  • Uploaded on

Object Query Language ( OQL ). Mari án Kamenišťák MFF – UK Praha 26.11.2003. Úvod. podobný SQL jazyku založený na ODMG štandarte Architektúra: Nástroje: C, C++, Java, … DB engine: napr. O2 engine & store Interfaces: O2ODBC, O2Cobra,. Z ákladné dotazy (C++).

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Object Query Language ( OQL )' - dragon


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
object query language oql

Object Query Language (OQL)

Marián Kamenišťák

MFF – UK Praha

26.11.2003

slide2
Úvod
  • podobný SQL jazyku
  • založený na ODMG štandarte
  • Architektúra:
    • Nástroje: C, C++, Java, …
    • DB engine: napr. O2 engine & store
    • Interfaces: O2ODBC, O2Cobra, ..
z kladn dotazy c
Základné dotazy (C++)
  • class item {String what; double price;};
  • class client {String name;

Array <item> order;

int amount();

};

z kladn dotazy
Základné dotazy
  • Select distinct e.salary

from e in Schema.employees

where e.family != nil

and e.position = “reporter”;

  • … where count(e.children) >=1;
  • … group by … having …
  • … order by … (vracia pole)
  • existujú agregačné fcie: min, max, sum, avg
tvorenie v sledkov
Tvorenie výsledkov
  • Define MyEmployees as

select struct(employee:

struct(e.name,

position: e.post),

salary: e.salary)

from e in Company.employees;

  • element (select e from e in MyEmployees where e.salary>150000);
mno inov oper tory
Množinové operátory
  • Zjednotenie(+): MyEmployees + YourEmployees
  • Prienik (*)
  • Rozdiel (-)
konverzie
Konverzie
  • listtoset(Companies[2].clients)
  • Naopak: select e from e in MyEmployees order by e.name;
  • z kolekcie kolekcií na plochú kolekciu:

flatten(select e.clients from c in Companies);

    • flatten(list(list(1,2), list(1,2,3)))

-> list(1,2,1,2,3)

  • ‘string’ like ‘%nice_%’
preddefinovan typy kolekci
Preddefinované typy kolekcií
  • Set<T> - mna
    • set(1,2,5)
  • Bag<T> - multimna
    • bag(1,2,2,3,3)
  • Varray<T> - dynamické pole
  • List<T> - Varray s metódami pre manipuláciu (insert, delete,..)
    • list(1,2,2,3); list(3..5)
  • Ref - perzistentný pointer
pokro il oql
Pokročilé OQL
  • class Person {

String name;

Date birth;

set<ref<Person>> childs inverse parents;

set<ref<Person>> parents inverse childs;

Person(); //constructor

void birth(ref<Person> child); //narodenie d.

virtual set<String> activities();

}

slide10
OQL
    • class Employee:Person{ //podtrieda

float salary;

virtual set<String> activities();//predefinit.

};

  • Join:
    • Select p from p in Persons,

b in (select a.building from a in Apartments)

Where p.name = b.address.street;

oql data manipulation
OQL – Data manipulation
  • select struct

(me:p.name, address:p.lives_in.building.address;

childs: (select struct(name: c.name,

address: c.lives_in.building.address)

from c in p.children)

)

from p in Persons;

//adresy detí cez všetky osoby.

oql polymorfizmus
OQL Polymorfizmus
  • napr. mna Persons obsahuje prvky tried Preson, Employee, Student.
  • Potom sa virtuálna metóda activities() vykoná pre konkrétnu triedu.
    • Select ((Student)p).grade

from p in Persons

where “lecture” in p.activities;

slide13
OQL
  • define salary_map as

select street,

average_salary: avg(select p.e.salary from partition p)

from e in Employees

group by e.lives_in.building.address.street;

//returns Bug<struct

{String street; float avg_salary;>};

slide14
OQL
  • define sorted_salary_map as

select s from s in salary_map

order by s.average_salary

List<struct

{String street; float avg_salary;}

>

  • sorted_salary_map[2].street;
slide15
OQL
  • define Jakes as

select x from Students x

where x.name = “Jake”;

  • define Jake as first(element(

select x from Students x

where x.name = “Jake”));

      • //first, last operators in list
slide16
OQL
  • Prechádzanie štruktúrami:
      • person.name == person->name //rovnaké
      • Jake->woman!=nil and Jake->woman->name=Carol
  • Dereferencie
      • p1 = p2 je pravda, ak ukazujú na rovnaký objekt
      • *p1 = *p2 je pravda, ak majú rovnaké hodnoty
oql group by
OQL - group by
  • select * from Employees e

group by

low: e.salary<1000,

medium: e.salary>=1000 and e.salary<2000,

high: e.salary>=2000;

Vytvorí pomenované partition bugy

literat ra
Literatúra
  • ODMG OQL user manual 5.0
    • feb. 1998
ad