Object Oriented Databases Bringing objects into databases.

Slides:



Advertisements
Similar presentations
Haskell Lets review some of the Haskell concepts you have been learning on your own. The answers are included, but try it yourself first.
Advertisements

Database Design The process of finding user requirement
พีชคณิตแบบสัมพันธ์ (Relational Algebra) บทที่ 3 อ. ดร. ชุรี เตชะวุฒิ CS (204)321 ระบบฐานข้อมูล 1 (Database System I)
Relational Algebra, Join and QBE Yong Choi School of Business CSUB, Bakersfield.
COP-5725 Practice Exercises
Relational Algebra Tim Kaddoura CS157A. Introduction  Relational query languages are languages for describing queries on a relational database  Three.
D ATABASE S YSTEMS I R ELATIONAL A LGEBRA. 22 R ELATIONAL Q UERY L ANGUAGES Query languages (QL): Allow manipulation and retrieval of data from a database.
Lecture 07: Relational Algebra
Relational Schemas and Predicate Logic: Notation.
Conceptual Data Modeling: ER
Relational Algebra Ch. 7.4 – 7.6 John Ortiz. Lecture 4Relational Algebra2 Relational Query Languages  Query languages: allow manipulation and retrieval.
Employee database: Conceptual Schema in ERD Chapter 3, page 62.
Database Systems Chapter 6 ITM Relational Algebra The basic set of operations for the relational model is the relational algebra. –enable the specification.
Object-Orientation in Query Languages By: Toan Nguyen Class: CS 157A.
Data models Relational, object, and semistructured.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Relational Algebra Chapter 4, Part A.
Modeller och språk för objekt-, relations- och webbdatabaser HT 2002.
Chapter 5 Relational Model Concepts Dr. Bernard Chen Ph.D. University of Central Arkansas.
Chapter 3 Data Modeling Using the Entity-Relationship (ER) Model.
CS848: Topics in Databases: Foundations of Query Optimization Topics Covered  Databases  QL  Query containment  More on QL.
Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.
Relational Model Concepts. The relational model represents the database as a collection of relations. Each relation resembles a table of values. A table.
1 CSE 480: Database Systems Lecture 11: SQL. 2 SQL Query SELECT FROM WHERE –In MySQL, FROM and WHERE clauses are optional –Example:
Chapter 2 Adapted from Silberschatz, et al. CHECK SLIDE 16.
ICOM 6005 – Database Management Systems Design Dr. Manuel Rodríguez Martínez Electrical and Computer Engineering Department Lecture 2 – Relational Model.
CIS552Relational Model1 Structure of Relational Database Relational Algebra Extended Relational-Algebra-Operations Modification of the Database.
Lecture 15: Relational Algebra
Assignements. CSC343: Intro. to Databases2 Exercise 1 Superkeys: Candidate keys: Primary key:
CS 103 Discrete Structures Lecture 10 Basic Structures: Sets (1)
ICS 321 Fall 2011 The Relational Model of Data (i) Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 8/29/20111Lipyeow.
The Relational Algebra and Calculus
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Database Management Systems Chapter 4 Relational Algebra.
Database Management Systems 1 Raghu Ramakrishnan Relational Algebra Chpt 4 Xin Zhang.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com ICOM 5016 – Introduction.
Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.
Chapter 2: Intro to Relational Model. 2.2 Example of a Relation attributes (or columns) tuples (or rows)
CSCD34-Data Management Systems - A. Vaisman1 Relational Algebra.
Data Modelling Using Entity-Relationship (ER) Model
CS848: Topics in Databases: Information Integration Topics covered  Databases  QL  Query containment  An evaluation of QL.
Database Management Systems, R. Ramakrishnan1 Relational Algebra Module 3, Lecture 1.
1 Spring 2000 Christophides Vassilis THE ODMG OBJECT QUERY LANGUAGE: OQL.
Relational Algebra Sample Questions.
Functional Programming Lecture 5 - Tuples. Packaging several values together Sometimes you need to package up several values into a single object –A function.
CMPT 258 Database Systems Relational Algebra (Chapter 4)
Relational Algebra p BIT DBMS II.
Relational Algebra COMP3211 Advanced Databases Nicholas Gibbins
©Silberschatz, Korth and Sudarshan2.1Database System Concepts - 6 th Edition Chapter 8: Relational Algebra.
Database Systems Chapter 6
Assignements.
Object-Oriented Databases and the ODMG Standard
Entity- Relationship (ER) Model
COMP3017 Advanced Databases
Introduction to Database Systems, CS420
Algebra substitution.
Computing Full Disjunctions
Database Design Determinacy.
Chapter 2: Intro to Relational Model
Chapter 2: Intro to Relational Model
بسم الله الرحمن الرحيم.
Relational Algebra 461 The slides for this text are organized into chapters. This lecture covers relational algebra, from Chapter 4. The relational calculus.
Database Systems 10/13/2010 Lecture #4.
Relational Databases The Relational Model.
Relational Databases The Relational Model.
LECTURE 3: Relational Algebra
Relational Algebra Sample Questions.
Chapter 2: Intro to Relational Model
Database Design Dr. M.E. Fayad, Professor
Syllabus Introduction Website Management Systems
Object – relational database
Relational Model B.Ramamurthy 5/28/2019 B.Ramamurthy.
Presentation transcript:

Object Oriented Databases Bringing objects into databases

An object database schema ADDRESS Street:String City:String PERSON SS#:String Name:String Address:Address EMPLOYEE ISA PERSON Salary:Integer Boss:Employee Departments:{Department} COMPANY Name: String Head quarters: Address Departments: {Department} CEO: Employee DEPARTMENT Name:String Office:Address Boss:Employee Employees:{Employee}

An object database query SELECT e.Name FROM e in EMPLOYEE, d in DEPARTMENT WHERE e in d.Employees AND e.Address.City = d.Office.City

Object database concepts Simple values Complex values Objects TypesClasses 25 #11‘bo’ {25,7} [a:1,b:2] PersonCar [ss#:String,age:Integer]

Simple and complex values A is the set of all attributes O is the set of all object identifiers D is the union of integers, reals, strings, and booleans Elements in O U D are called simple values Elements of the form [A 1 :w 1, …, A n :w n ] are tuple values where A i is an attribute and w i a value Elements of the form {w 1, …, w n } are set values A complex value is a tuple value or a set value

Objects An object is a pair (o, w) o is an object identifier w is a value

Examples of objects A = {SS#, Name, Address, Main office, Departments, CEO} O = {#11, #12, #13, #14, #21, #31, #41} z(#11, [SS#: ‘ ’, Name: ‘Bo Ek’, Address: [Street: ‘Storg. 4’, Town: ‘Karlstad’]]) z(#14, [Name: ‘Acme’, Head office: [Street: ‘Storg. 12’, Town: ‘Karlstad’], Departments: {#21, #31, #41}, CEO: #11])

Value and object equality zValue equality Two objects are equal if their values are equal (o 1, w 1 ) = (o 2, w 2 ) iff w 1 = w 2 zObject equality Two objects are equal if their object identifiers are the same (o 1, w 1 ) = = (o 2, w 2 ) iff o 1 = o 2

Surface and deep equality Surface equality: equality without substituting object references Deep equality: equality after substituting object references by values w 1 = [A: o 1 ] w 2 = [A: o 2 ] (o 1, w) (o 2, w) where o 1  o 2 w1 not surface equal to w2 w1 deep equal to w2

Surface and deep equality w 1 = [A: o 1, B: 25] w 2 = [A: o 2, B: o 3 ] w 3 = [A: o 2, B: o 4 ] (o 1, 25) (o 2, 50) (o 3, 25) (o 4, o 1 ) w 1 deep equal to w 2 ? w 1 deep equal to w 3 ? w 2 deep equal to w 3 ?

Types and classes Intuitions: zValues with the same structure are described by a type zObject identifiers for similar objects are grouped into a class A class can be associated with a type to specify the structure of the objects of the class A class can be used as a type for typing references between objects

Types Let K be a set of classes. zBase types: {integer, float, string, boolean} zReference types: K zTuple types: elements of the form [A 1 :T 1, …, A n :T n ], where A i is an attribute and T i en typa type zSet types: {T}, where T is a type A complex type is a tuple type or a set type

An example type K = {Car, Company, City} EMPLOYEE SS#:Integer Name:String Lives in:City Works at:Company Owns:{Car} Base type Reference type Set type Tuple type

Object database schema An object database schema consists of: zA set of class names K zFor each k in K, a type that specifies the structure of k

Object database extension zGiven an object database schema S, an extension for S associates each k in K with a set of object identifiers

An example extension Animal Mammal Bird Dog K #1 #2 #3 #4 #5 #1 #2 #3 #4 #5

Types, classes, objects, and values Person Bil #11 #12 #22 #21 [Regnr: String, Färg: String, Ägare: Person] [Pnr: String, Namn: String, Lön: Integer] [Pnr: ‘ ’, Namn: ‘Per Svensson’, Lön: 25000] [Regnr: ‘ABC123’, Färg: ‘Röd’, Ägare: #11] K Types W O

Query languages zAllmängiltighet zDeklarativitet zOptimerbarhet zSlutenhet zUttryckskraft zUtvidgningsbarhet

Two simple queries SELECT a FROM a in EMPLOYEE WHERE Salary > SELECT SS#, Name FROM EMPLOYEE WHERE Salary > 20000

Path expressions (dot notation) SELECT Name FROM Company WHERE Head_quarters.City = “London” SELECT Name, Head_quarters.Street FROM Company WHERE Head_quarters.City = “London”

Sets in queries What does this query mean? SELECT c FROM c in COMPANY WHERE CEO IN (SELECT e FROM e in EMPLOYEE WHERE Employee.Address.City = “Lund”)

Sets in queries SELECT c.Name FROM c in COMPANY WHERE c.Departments.Office.City = {“London”, “Lund”}

Sets and dot notation SELECT c.Departments.Employees.Salary FROM c in COMPANY c.Departments.Employees.Salary {f1, f2, f3} {a1, a2} {a3, a4} {a5} {f1, f2, f3} {{a1, a2}, {a3, a4}, {a5}} ? {a1, a2, a3, a4, a5} ?

Sets and dot notation SELECT c.Departments.Employees.Salary FROM c in COMPANY {f1, f2, f3} {a1, a2} {a3, a4} {a5} Answer: {100, 150, 200}

Exercises zWhich employees work at the same departments as their bosses? zWhich (pair of) employees work at the same departments? zWhich companies do not have any employee living in London? zIn which companies do all employees live in London?

Exercises zWhich employees work only at departments that are situated in London? zWhich employees do not work at a department in London? These queries become harder if the attribute “Departments” is removed. Try to write the queries also without this attribute.

Exercises zIn which companies are there employees who live in cities where the company does not have any department? zIn which companies does the boss of each employee live in the same city as the employee?

zWhich employees work at the same departments as their bosses?

zWhich (pair of) employees work at the same departments?

zWhich companies do not have any employee living in London?

zIn which companies do all employees live in London?

zWhich employees work only at departments that are situated in London?

zWhich employees do not work at a department in London?

zIn which companies are there employees who live in cities where the company does not have any department?

zIn which companies does the boss of each employee live in the same city as the employee?

zWhich employees work at the same departments as their bosses? SELECT e.Name FROM e in EMPLOYEE WHERE e.Departments = e.Boss.Departments

zWhich (pair of) employees work at the same departments? SELECT e1.Name, e2.Name FROM e1 in EMPLOYEE, e2 in EMPLOYEE WHERE e1.Departments = e2.Departments

zWhich companies do not have any employee living in London? SELECT c FROM c in COMPANY WHERE ‘London’ NOT IN c.Departments.Employees.Address.City

zIn which companies do all employees live in London? SELECT c FROM c in COMPANY WHERE c.Departments.Employees.Address.City = {‘London’}

zWhich employees work only at departments that are situated in London? SELECT e.Name FROM e IN EMPLOYEE WHERE NOT EXISTS (SELECT d FROM DEPARTMENT WHERE e in d.Employees AND d.Office.City <> ‘London’) SELECT e.Name FROM e in EMPLOYEE WHERE e.Departments.Office.City = {‘London’}

zWhich employees do not work at a department in London? SELECT e.Name FROM e in EMPLOYEE WHERE NOT EXISTS (SELECT d FROM d in DEPARTMENT WHERE e in d.Employees AND d.Office.City = ‘London’) SELECT e.Name FROM e in EMPLOYEE WHERE ‘London’ NOT IN e.Departments.Office.City

zIn which companies are there employees who live in cities where the company does not have any department? SELECT c FROM c IN COMPANY WHERE c.Departments.Employees.Address.City MINUS c.Departments.Office.City <> Ø

zIn which companies does the boss of each employee live in the same city as the employee? SELECT c FROM c in COMPANY WHERE NOT EXISTS (SELECT e FROM e in EMPLOYEE WHERE e IN c.Departments.Employees AND e.Boss.Address.City <> e.Address.City)

zWhich employees work at a department in a city where they do not live? SELECT e.Name FROM e in EMPLOYEE, d in DEPARTMENT WHERE e in d.Employees AND d.Office.City <> e.Address.City

zWhich employees live in the same city as (at least one of) their boss(es)? SELECT e.Name FROM e in EMPLOYEE, d in DEPARTMENT WHERE e in d.Employees AND e.Address.City = d.Boss.Address.City