Object query language oql
This presentation is the property of its rightful owner.
Sponsored Links
1 / 18

Object Query Language ( OQL ) PowerPoint PPT Presentation


  • 46 Views
  • Uploaded on
  • Presentation posted in: General

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++).

Download Presentation

Object Query Language ( OQL )

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


Object query language oql

Ú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();

    }


Object query language oql

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;


    Object query language oql

    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;>};


    Object query language oql

    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;


    Object query language oql

    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


    Object query language oql

    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


  • Login