1 / 10

Object Oriented Databases

Object Oriented Databases. Seminar 11 Exploring ODMG standard Using OPTGEN. Example Schema in ODL. interface department ( extent Departments ) { attribute String name; attribute Short dno; attribute String address; }; interface person ( extent Persons )

monte
Download Presentation

Object Oriented Databases

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Object Oriented Databases Seminar 11 Exploring ODMG standard Using OPTGEN Advanced Database: Seminar 11 (Object-Oriented Databases)

  2. Example Schema in ODL interface department ( extent Departments ) { attribute String name; attribute Short dno; attribute Stringaddress; }; interface person ( extent Persons ) { attribute String name; attribute Short age; }; interface employee:person ( extent Employees ) { attribute String address; attribute set<person> children; attribute department dept; attribute employee manager; }; • OPTGEN: An experimental optimizer for OQL, is a research project based on ODMG-93 – an earlier form of ODMG 2 standard. • interface in ODMG-93 can be used in place of a class and we can create instances of it. However, in ODMG 2, it is not instantiable. • An extent denotes the set of objects of a particular type e.g. Departments is a set of all department object. • OPTGEN does not support inverse relationships. Advanced Database: Seminar 11 (Object-Oriented Databases)

  3. Object Creation – the Database department d1:= department("R&D", 1, "Newcastle"); department d2 := department("IS", 2, "Gateshead"); department d3 := department("CSE", 3, "Durham"); department d4 := department("EE", 4, "SouthShield"); person kid1 := person("Nick", 2); person kid2 := person("Jim", 3); person kid3 := person("Jennifer", 8); person kid4 := person("Henah", 5); employee e1 := employee("Smith", 40, "Jesmond", set(kid1, kid2), d1, null); employee e2 := employee("Tim", 40, "Durham", set(kid3), d2, null); employee e3 := employee("Jones", 40, "Gosforth", set(), d1, e1); employee e4 := employee("Leo", 35, "Fenham", set(), d3, e2); employee e5 := employee("Peter", 31, "Newcastle", set(kid4), d4, null); employee e6 := employee("Tony", 23, "Sunderland", set(), d4, e5); Advanced Database: Seminar 11 (Object-Oriented Databases)

  4. Querying using OQL • Simple Query • Named objects – entry points • Path expressions The query returns names of employees such that the type of the result is bag<string>. select e.name from e in Employees; The query returns all department objects. The type of the query is set<department>. Departments; The query returns name of the department of the named object e6, which is of type string. e6.dept.name; Advanced Database: Seminar 11 (Object-Oriented Databases)

  5. Querying using OQL – continued … • An Implicit Join Query • Joining and Unnesting The query returns names of employees and their department by joining them (but the query does not include any join). The type of the result is bag<E:string, D:string>. select struct(E:e.name,D:e.dept.name) from e in Employees where e.age >35; select struct(E:e.name, EA:e.address, C:k.name) from d in Departments, e in Employees, k in e.children where e.address = d.address; The query returns names of employees and their addresses and their children names. There is an explicit join between Employees and Departments and Unnest for getting the names of children. The type of the query bag<E:string, EA:string, C:string>. Advanced Database: Seminar 11 (Object-Oriented Databases)

  6. Querying using OQL – continued … • A Nesting Query select struct(Dname:d.name, Staff: (select e.name from e in Employees where e.dept = d)) from d in Departments; The query returns names of departments and their employees. There is an explicit join in the inner query, and in the outer query the result of the inner query is assigned to variable Staff. The type of the query bag<Dname:string, Staff:bag<string>>. Advanced Database: Seminar 11 (Object-Oriented Databases)

  7. OPTGEN Query Outputs • 1) Query in OQL: select e.name from e in Employees; • Query result type:bag(String) The result is: collection("Smith","Tim","Jones","Leo","Peter", “Tony") • 2) Query in OQL: e6.dept.name; • Query result type:String The result is: "EE" Advanced Database: Seminar 11 (Object-Oriented Databases)

  8. OPTGEN Query Outputs … • 3) Query in OQL: select struct(E:e.name, D:e.dept.name) from e in Employees where e.age >35; • Query result type:bag(struct(bind(E,String),bind(D,String))) Advanced Database: Seminar 11 (Object-Oriented Databases)

  9. OPTGEN Query Outputs … • 4) Query in OQL: select struct(E:e.name, EA:e.address, C:k.name) from d in Departments, e in Employees, k in e.children where e.address = d.address; • Query result type: bag(struct(bind(E,String),bind(EA,String),bind(C,String))) Advanced Database: Seminar 11 (Object-Oriented Databases)

  10. OPTGEN Query Outputs … • 5) Query in OQL: select struct(Dname:d.name, Staff: (select e.name from e in Employees where e.dept = d)) from d in Departments; • Query result type: bag(struct(bind(Dname,String),bind(Staff,bag(String)))) Advanced Database: Seminar 11 (Object-Oriented Databases)

More Related