CHAPTER 14 USING RELATIONAL DATABASES TO PROVIDE OBJECT PERSISTENCE (ONLINE) © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database.

Slides:



Advertisements
Similar presentations
Database System Concepts and Architecture
Advertisements

.NET Database Technologies: Open-Source Frameworks.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 13 Introduction to SQL Programming Techniques.
--What is a Database--1 What is a database What is a Database.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
12-1 © Prentice Hall, 2004 Chapter 12: Design Elements Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich, Jeffrey.
RIZWAN REHMAN, CCS, DU. Advantages of ORDBMSs  The main advantages of extending the relational data model come from reuse and sharing.  Reuse comes.
Session-01. Hibernate Framework ? Why we use Hibernate ?
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 12-1 David M. Kroenke’s Chapter Twelve: ODBC Database Processing: Fundamentals,
Data Persistence and Object-Relational Mapping Slides by James Brucker, used with his permission 1.
Object Persistence and Object-Relational Mapping James Brucker.
Introduction to JPA Java Persistence API Introduction to JPA.
Object and object-relational databases 1. Object databases vs. Object-relational databases Object databases Stores complex objects – Data + functions.
Copyright © 2004 Pearson Education, Inc. Chapter 1 Introduction.
1 Web Database Processing. Web Database Applications Static Report Publishing a report is prepared from a database application and exported to HTML DB.
Chapter 13 (Online): Object-Oriented Databases
CHAPTER 1: THE DATABASE ENVIRONMENT AND DEVELOPMENT PROCESS Modern Database Management 11 th Edition Jeffrey A. Hoffer, V. Ramesh, Heikki Topi © 2013 Pearson.
Database System Concepts and Architecture Lecture # 3 22 June 2012 National University of Computer and Emerging Sciences.
Entity Framework Code First End to End
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 7-1 David M. Kroenke’s Chapter Seven: SQL for Database Construction and.
LINQ Boot Camp ADO.Net Entity Framework Presenter : Date : Mahesh Moily Nov 26, 2009.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 8 (Part b): Advanced SQL Modern Database Management 9 th Edition Jeffrey A. Hoffer,
Entity Framework, a quickstart Florin−Tudor Cristea, Microsoft Student Partner.
1 © Prentice Hall, 2002 Chapter 8: The Client/Server Database Environment Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott,
Data Access Patterns Some of the problems with data access from OO programs: 1.Data source and OO program use different data modelling concepts 2.Decoupling.
NHibernate in Action Web Seminar at UMLChina By Pierre Henri Kuaté 2008/08/27
© D. Wong  Indexes  JDBC  JDBC in J2EE (Java 2 Enterprise Edition)
Modern Database Techniques Part 1: Object Oriented Databases 3. Different Kinds of OODB.
Information System Development Courses Figure: ISD Course Structure.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Database System Concepts and Architecture.
CHAPTER 13 (ONLINE): OBJECT-ORIENTED DATA MODELING © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition.
© 2011 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 14 Using Relational Databases to Provide Object Persistence (Overview) Modern Database.
© 2011 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 13 (Online): Object-Oriented Data Modeling Modern Database Management 10 th Edition.
CHAPTER 13: OBJECT-ORIENTED DATA MODELING (OVERVIEW) © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition.
Hibernate Persistence. What is Persistence Persist data to database or other storage.  In OO world, persistence means persist object to external storage.
1 Mapping to Relational Databases Presented by Ramona Su.
An Introduction to Object/Relational Persistence and Hibernate Yi Li
Oct * Brad Tutterow. VS 2008.NET 3.5LINQ Entity Framework  The ADO.NET Entity Framework is part of Microsoft’s next generation of.NET technologies.
CHAPTER 6: INTRODUCTION TO SQL © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey A. Hoffer,
Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition Copyright © 2004 Pearson Education, Inc. Slide 2-1 Data Models Data Model: A set.
JPA / HIBERNATE CSCI 6370 Nilayan Bhattacharya Sanket Sable.
CIS/SUSL1 Fundamentals of DBMS S.V. Priyan Head/Department of Computing & Information Systems.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Database System Concepts and Architecture.
Fall CIS 764 Database Systems Engineering L18.2 : Object Relational Mapping … ….Object persistence.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 12-1 David M. Kroenke’s Chapter Twelve: ODBC, OLE DB, ADO, and ASP Part.
Topic : Hibernate 1 Kaster Nurmukan. An ORM tool The problem fixed by ORM Advantage Hibernate Hibernate Basic –Hibernate sessionFactory –Hibernate Session.
Persistent State Service 1  Concept  Persistence is the ability of an object state to survive termination of the process in which the object executes.
CSE323 การวิเคราะห์และออกแบบระบบ (Systems Analysis and Design) Lecture 12: Data Management Design.
Hibernate Basics. Basics What is persistence? Persistence in Object Oriented Applications? Paradigm Mismatch.  The Problem of Granularity.  The Problem.
Chapter 1 © 2013 Pearson Education, Inc. Publishing as Prentice Hall Chapter 1: The Database Environment and Development Process Modern Database Management.
Introduction Because database applications today reside in a complicated environment, various standards have been developed for accessing database servers.
Topic : Hibernate 1 Kaster Nurmukan. An ORM tool Used in data layer of applications Implements JPA.
Introduction – ORM, Helloworld Application
Fundamentals of MyBATIS
Introduction to ORM Hibernate Hibernate vs JDBC. May 12, 2011 INTRODUCTION TO ORM ORM is a programming technique for converting data between relational.
ORM Basics Repository Pattern, Models, Entity Manager Ivan Yonkov Technical Trainer Software University
Copyright © 2016 Pearson Education, Inc. Modern Database Management 12 th Edition Jeff Hoffer, Ramesh Venkataraman, Heikki Topi CHAPTER 6: INTRODUCTION.
CS422 Principles of Database Systems Object-Relational Mapping (ORM) Chengyu Sun California State University, Los Angeles.
CS520 Web Programming Object-Relational Mapping with Hibernate and JPA (I) Chengyu Sun California State University, Los Angeles.
CS 440 Database Management Systems Stored procedures & OR mapping 1.
Hibernate Online Training. Introduction to Hibernate Hibernate is a high-performance Object-Relational persistence and query service which takes care.
Hibernate Java Persistence API. What is Persistence Persistence: The continued or prolonged existence of something. Most Applications Achieve Persistence.
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Lecture 9: The Client/Server Database Environment Modern Database Management 9 th Edition.
Chapter 2 Database System Concepts and Architecture
POOL persistency framework for LHC
Entity Framework By: Casey Griffin.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Database System Concepts and Architecture.
Hibernate Bayu Priyambadha, S.Kom.
Database Processing: David M. Kroenke’s Chapter Twelve: Part One
Presentation transcript:

CHAPTER 14 USING RELATIONAL DATABASES TO PROVIDE OBJECT PERSISTENCE (ONLINE) © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey A. Hoffer, V. Ramesh, Heikki Topi

Chapter 14-Web © 2013 Pearson Education, Inc. Publishing as Prentice Hall OBJECTIVES  Define terms  Understand mismatch between object-oriented and relational paradigms and the consequences of mismatch  Understand similarities and differences between approaches used to address object-relational mismatch  Create mapping between OO structures and relational structures using Hibernate  Identify primary contexts for the different approaches of addressing the object-relational mismatch  Understand performance, concurrency, and security effects of object-relational mapping  Use HQL to formulate queries 2

3 Chapter 14-Web © 2013 Pearson Education, Inc. Publishing as Prentice Hall 3

Chapter 14-Web © 2013 Pearson Education, Inc. Publishing as Prentice Hall STORAGE IN OO SYSTEMS  Persistence  An object’s capacity to maintain its state between application execution sessions  Serialization  Writing an object onto a storage medium or a communication channel as a data stream  Object-relational mapping (ORM)  Defining structural relationships between object- oriented and relational representations of data, typically to enable the use of a relational database to provide persistence for objects 4

Chapter 14-Web © 2013 Pearson Education, Inc. Publishing as Prentice Hall OBJECT-RELATIONAL IMPEDANCE MISMATCH  Conceptual differences between the object-oriented approach to application design and the relational model for database design/implementation 5

Chapter 14-Web © 2013 Pearson Education, Inc. Publishing as Prentice Hall OBJECT IDENTITY AND ACCESS  Object identity  Property of an object separating it from other objects based on its existence  Accessor method  A method that provides other objects with access to the state of an object 6

7 Chapter 14-Web © 2013 Pearson Education, Inc. Publishing as Prentice Hall 7 Object-oriented navigation is done via accessor methods on attributes; whereas with relational databases,it is typically done via a single join query.

Chapter 14-Web © 2013 Pearson Education, Inc. Publishing as Prentice Hall PROVIDING OBJECT PERSISTENCE USING RELATIONAL DATABASES  Call-level Application Program Interface (API)  SQL Mapping Frameworks  Object-Relational Mapping Frameworks  Proprietary Approaches 8

Chapter 14-Web © 2013 Pearson Education, Inc. Publishing as Prentice Hall CALL-LEVEL APIS  SQL query hand-coded by programmer passed as parameter to driver  Examples: Java Database Connectivity (JDBC), ADO.NET, Open Database Connectivity (ODBC) 9

Chapter 14-Web © 2013 Pearson Education, Inc. Publishing as Prentice Hall SQL QUERY MAPPING FRAMEWORKS  Allow developers to operate at a higher level of abstraction  Examples: MyBatis and MyBatis.NET 10

Chapter 14-Web © 2013 Pearson Education, Inc. Publishing as Prentice Hall OBJECT RELATIONAL MAPPING FRAMEWORKS (ORM)  Transparent persistence: Hides underlying storage technology  Declarative Mapping Schema: Defines relationship between OO classes and database relations/tables  Examples: Hibernate, JDO, Java Persistence API (JPA) 11

Chapter 14-Web © 2013 Pearson Education, Inc. Publishing as Prentice Hall PROPRIETARY FRAMEWORKS  Example:  Microsoft’s Language Integrated Query (LINQ)  Goal:  very closely integrate data access queries into programming languages, not limiting the access to relational databases or XML but any type of data store 12

Chapter 14-Web © 2013 Pearson Education, Inc. Publishing as Prentice Hall EXAMPLE HIBERNATE MAPPING 13 Figure 14-3 Object-oriented domain model

14 Chapter 14-Web © 2013 Pearson Education, Inc. Publishing as Prentice Hall 14

Chapter 14-Web © 2013 Pearson Education, Inc. Publishing as Prentice Hall EXAMPLE HIBERNATE MAPPING 15

Chapter 14-Web © 2013 Pearson Education, Inc. Publishing as Prentice Hall EXAMPLE HIBERNATE MAPPING 16 Figure 14-6 Relational database implementation

Chapter 14-Web © 2013 Pearson Education, Inc. Publishing as Prentice Hall EXAMPLE HIBERNATE MAPPING 17 An ORM mapping

Chapter 14-Web © 2013 Pearson Education, Inc. Publishing as Prentice Hall EXAMPLE HIBERNATE MAPPING 18 Another ORM mapping

Chapter 14-Web © 2013 Pearson Education, Inc. Publishing as Prentice Hall EXAMPLE HIBERNATE MAPPING 19 Another ORM mapping

Chapter 14-Web © 2013 Pearson Education, Inc. Publishing as Prentice Hall EXAMPLE HIBERNATE MAPPING 20 Hibernate’s SchemaExport tool generates DDL from ORM mappings

Chapter 14-Web © 2013 Pearson Education, Inc. Publishing as Prentice Hall MAPPING OO STRUCTURES TO A RELATIONAL DATABASE 21

Chapter 14-Web © 2013 Pearson Education, Inc. Publishing as Prentice Hall 22

Chapter 14-Web © 2013 Pearson Education, Inc. Publishing as Prentice Hall MAPPING OO STRUCTURES TO A RELATIONAL DATABASE 23

Chapter 14-Web © 2013 Pearson Education, Inc. Publishing as Prentice Hall MAPPING OO STRUCTURES TO A RELATIONAL DATABASE 24

Chapter 14-Web © 2013 Pearson Education, Inc. Publishing as Prentice Hall MAPPING OO STRUCTURES TO A RELATIONAL DATABASE 25

Chapter 14-Web © 2013 Pearson Education, Inc. Publishing as Prentice Hall RESPONSIBILITIES OF ORM MAPPING FRAMEWORKS  Providing a layer of abstraction between OO applications and a database schema implemented with a DBMS ➝ transparent persistence  Generating SQL code for database access  Centralizing code related to database access  Support for transaction integrity and management  Services for concurrency control  Query language (e.g. Hibernate’s HQL) 26

Chapter 14-Web © 2013 Pearson Education, Inc. Publishing as Prentice Hall ORM DATABASE PERFORMANCE MANAGEMENT  Fetching strategy – a model for specifying when and how an ORM framework retrieves persistent objects to the run-time memory during a navigation process  N+1 selects problem – a performance problem caused by too many SELECT statements generated by an ORM framework  Lazy vs. eager loading 27

Chapter 14-Web © 2013 Pearson Education, Inc. Publishing as Prentice Hall HIBERNATE’S HQL QUERY LANGUAGE  Similar to SQL  Different approaches to handling joins  Implicit association join  Ordinary join in FROM clause  Fetch join in FROM clause  Theta-style join in WHERE clause 28 From Bauer and King (2006, p645)

Chapter 14-Web © 2013 Pearson Education, Inc. Publishing as Prentice Hall SAMPLE HQL QUERY  Implicit join(simple many-to-one) 29  Equivalent SQL query

Chapter 14-Web © 2013 Pearson Education, Inc. Publishing as Prentice Hall SAMPLE HQL QUERY 30  Explicit join(complex many-to-one)  Equivalent SQL query

Chapter 14-Web © 2013 Pearson Education, Inc. Publishing as Prentice Hall SAMPLE HQL QUERY  Aggregate query with join 31

32 Chapter 14-Web © 2013 Pearson Education, Inc. Publishing as Prentice Hall