Fall 2009ACS-3913 R McFadyen1 Persistent Objects Persistent objects are objects that continue to exist after the application program terminates Persistence.

Slides:



Advertisements
Similar presentations
Chapter 10: Designing Databases
Advertisements

Chapter 3 Data Modeling Copyright © 2014 McGraw-Hill Education. All rights reserved. No reproduction or distribution without the prior written consent.
March 27, R McFadyen1 OR Mapping - Example When we map this structure to a Relational Database, we are creating an object-to-relational mapping.
OBJECTS Object Oriented ???????. OBJECTS Object-Oriented n OO convenient label for a collection of interconnected ideas n OO approach views computer.
Concepts of Database Management Sixth Edition
Database Systems: A Practical Approach to Design, Implementation and Management International Computer Science S. Carolyn Begg, Thomas Connolly Lecture.
3-1 Chapter 3 Data and Knowledge Management
Physical Database Monitoring and Tuning the Operational System.
Mar 20, R McFadyen1 Persistent Objects Persistent objects are objects that continue to exist after the application program terminates Persistence.
March 31, R McFadyen1 Persistent Objects Persistent objects are objects that continue to exist after the application program terminates Persistence.
Fall 2009ACS-4902 R McFadyen1 OODBMS Native ODBMS db4o Consider the model for the Persistence example on the web site section student *
Concepts of Database Management Seventh Edition
Chapter 12 Database Connectivity with ASP.NET JavaScript, Third Edition.
RIZWAN REHMAN, CCS, DU. Advantages of ORDBMSs  The main advantages of extending the relational data model come from reuse and sharing.  Reuse comes.
Chapter 17 Methodology – Physical Database Design for Relational Databases Transparencies © Pearson Education Limited 1995, 2005.
Team Dosen UMN Physical DB Design Connolly Book Chapter 18.
Mapping ERM to relational database
CSE446 S OFTWARE Q UALITY M ANAGEMENT Spring 2014 Yazılım ve Uyguluma Geliştirme Yöneticisi Orhan Başar Evren.
Databases From A to Boyce Codd. What is a database? It depends on your point of view. For Manovich, a database is a means of structuring information in.
Chapter 4 The Relational Model.
DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
CSC271 Database Systems Lecture # 4.
Geog 495 GIS Database Design Midterm review. Outlines 1.Database Concepts 2.Relational Database 3.Object-oriented Database 4.Entity-Relationship Diagram.
CS 160: Software Engineering October 8 Class Meeting
Lecture 9 Methodology – Physical Database Design for Relational Databases.
1 Introduction to Database Systems. 2 Database and Database System / A database is a shared collection of logically related data designed to meet the.
Management Information Systems By Effy Oz & Andy Jones
CHAPTER 14 USING RELATIONAL DATABASES TO PROVIDE OBJECT PERSISTENCE (ONLINE) © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database.
CODD’s 12 RULES OF RELATIONAL DATABASE
Chapter 16 Methodology – Physical Database Design for Relational Databases.
Databases From A to Boyce Codd. What is a database? It depends on your point of view. For Manovich, a database is a means of structuring information in.
Object Oriented Analysis and Design 1 Chapter 7 Database Design  UML Specification for Data Modeling  The Relational Data Model and Object Model  Persistence.
Team Dosen UMN Database Design Connolly Book Chapter
Lecture2: Database Environment Prepared by L. Nouf Almujally & Aisha AlArfaj 1 Ref. Chapter2 College of Computer and Information Sciences - Information.
Object Persistence Design Chapter 13. Key Definitions Object persistence involves the selection of a storage format and optimization for performance.
Chapter 12: Designing Databases
1 Relational Databases and SQL. Learning Objectives Understand techniques to model complex accounting phenomena in an E-R diagram Develop E-R diagrams.
Concepts of Database Management Sixth Edition Chapter 6 Database Design 2: Design Method.
Lecture2: Database Environment Prepared by L. Nouf Almujally 1 Ref. Chapter2 Lecture2.
10/10/2012ISC239 Isabelle Bichindaritz1 Physical Database Design.
© 2005 Prentice Hall10-1 Stumpf and Teague Object-Oriented Systems Analysis and Design with UML.
Designing a Persistence Framework With Patterns
Chapter 38 Persistence Framework with Patterns 1CS6359 Fall 2011 John Cole.
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition Copyright © 2009 John Wiley & Sons, Inc. All rights.
Access Review. Access Access is a database application A database is a collection of records and files organized for a particular purpose Access supports.
Concepts of Database Management, Fifth Edition Chapter 6: Database Design 2: Design Methodology.
Methodology – Physical Database Design for Relational Databases.
Nov 20, R McFadyen1 Persistent Objects Key ideas/definitions UML representations Mapping patterns Transactional states Example Some commercial.
CIS/SUSL1 Fundamentals of DBMS S.V. Priyan Head/Department of Computing & Information Systems.
Switch off your Mobiles Phones or Change Profile to Silent Mode.
CS263 Lecture 5: Logical Database Design Can express the structure of a relation by a Tuple, a shorthand notation Name of the relation is followed (in.
The ODMG Standard for Object Databases
Database Connectivity with ASP.NET. 2 Introduction Web pages commonly used to: –Gather information stored on a Web server database Most server-side scripting.
Elaboration Iteration 3 – Part 3 - Persistence Framework -
Object storage and object interoperability
March 1, 2004CS WPI1 CS 509 Design of Software Systems Lecture #6 Monday, March 1, 2004.
Mapping Objects ↔Relational DB. The Problem with Databases Databases store data in rows in tables, which are not like objects. We can simulate object.
Database Design Slide 1 Database Design Lecture 7 part 2 Mapping ERD to Tables.
DESIGNING A PERSISTENCE FRAMEWORK WITH PATTERNS. The Problem: Persistent Objects persistent object An object that can survive the process or thread that.
Chapter 2 Database Environment.
Chapter 3: Relational Databases
Faeez, Franz & Syamim.   Database – collection of persistent data  Database Management System (DBMS) – software system that supports creation, population,
LECTURE TWO Introduction to Databases: Data models Relational database concepts Introduction to DDL & DML.
Database Planning Database Design Normalization.
1 Management Information Systems M Agung Ali Fikri, SE. MM.
Relational vs. Object Oriented Database Management System Syazwani Nur Dayana Nur Fatin Syafiqa M3cs2305B.
ISC321 Database Systems I Chapter 2: Overview of Database Languages and Architectures Fall 2015 Dr. Abdullah Almutairi.
Introduction to Database Programming with Python Gary Stewart
ISC321 Database Systems I Chapter 10: Object and Object-Relational Databases: Concepts, Models, Languages, and Standards Spring 2015 Dr. Abdullah Almutairi.
Presentation transcript:

Fall 2009ACS-3913 R McFadyen1 Persistent Objects Persistent objects are objects that continue to exist after the application program terminates Persistence is provided by a DBMS ACID properties … D: durable or persistent Two main categories OODBMS RDBMS Chapter 38: Intro, 1- 2, 4 - 9,

Fall 2009ACS-3913 R McFadyen2 OODBMS An ODBMS is a DBMS which stores objects Depending on how an ODBMS implementation chooses to persist objects, there are two types of ODBMS: non-native and native

Fall 2009ACS-3913 R McFadyen3 OODBMS Non-native ODBMS In a non-native object database, there are two separate object models, one of the application and the other of the database itself. ODMG-compliant ODBMSs are examples of non-native ODBMSs since they require a separate data schema to be defined, regardless of the existence of the application object model. In order to query or persist objects from and to non- native object databases, a mapping between these two distinct models is required.

Fall 2009ACS-3913 R McFadyen4 OODBMS Native ODBMS In native object databases, objects are stored exactly as they are, without the need to map them into a different object model supported by the databases and vice versa. In the world of native object databases, there is just one single object model: the application object model databases are not easily portable across applications, languages, platforms

Fall 2009ACS-3913 R McFadyen5 OODBMS Native ODBMS e.g. db4o Consider the model for the Persistence example on the web site section student *

Fall 2009ACS-3913 R McFadyen6 OODBMS import …Makes the db4o classes available to us. ObjectContainer db = Db4o.openFile(“…”); If the database does not exist, db4o creates it. The database is then opened for use. db.commit();This statement ends the current transaction. It indicates the end of a unit of work that must be committed in its entirety to the database. db.close();This statement closes the database for us and makes it available to another application. db.store(section);This one statement is all that is necessary to have the section object saved to the database.

Fall 2009ACS-3913 R McFadyen7 OODBMS Consider code in folder Persistence example on web site: SectionDriver, Section, and Student comprise a 1903 example using arrays of objects CreateStudentDatabase: creates a database of sections where a section contains student objects ListDatabase: lists section objects and student objects in database ClearDatabase: removes all sections and students from the database

Fall 2009ACS-3913 R McFadyen8 RDBMS Because RDBMSs are used so heavily in practice, objects must be stored and retrieved from an RDBMS The mismatch between the object representation of data and the relational representation leads to difficulties. A mapping between the two models is required to be implemented. Relations have Primary Keys, Foreign keys Data types Complex objects vs tuples Inheritance Collections of objects Larman examines how a framework for an O-R mapping service should be constructed

Fall 2009ACS-3913 R McFadyen9 Architectural layers Relational Database NextgenPOS User Interface Application Technical Services O/R Mapping Service

Fall 2009ACS-3913 R McFadyen10 Patterns Representing Objects as Tables 38.6 Object Identifier 38.8 Façade 38.9 Representing Object Associations as Tables one-to-one one-to-many many-to-many many-to-many with an Association Class Aggregation and Composition Superclass/Subclass

Fall 2009ACS-3913 R McFadyen11 Persistent Objects in an RDBMS To use an RDBMS for NextGenPOS, we require an object to relational mapping service persistence service is a subsystem within the Technical Services Layer mismatch between record-oriented and object-oriented representations of data recommendation : buy, not build Hibernate, Toplink, Glassfish provides functions such as store, retrieve, modify, commit, rollback

Fall 2009ACS-3913 R McFadyen12 Key Ideas Mapping There are two schemas: object and relational. A mapping is required that translates from one to the other. Object Identity Records and objects have a unique identifier Materialization/Dematerialization need to be able to translate the non-object representation to an object representation, and vice versa Lazy Materialization Some objects are not materialized all-at-once; part of the object may be done first, and other parts later on

Fall 2009ACS-3913 R McFadyen13 Each class becomes a table Representing Objects as Tables pattern define a table for each persistent object class Some mappings are straight forward ClassAn objectThe table Many of these patterns mentioned come from a paper “Crossing Chasms: A Pattern Language for Object-RDBMS” published in 1996 in Pattern Languages of Program Design

Fall 2009ACS-3913 R McFadyen14 > stereotype We can indicate tables in UML using the stereotype: > Note you can use UML for designing relational databases

Fall 2009ACS-3913 R McFadyen15 OIDs We can use the OID to prevent from instantiating the same object twice and to help find an instance Objects have an OID that is used as the PK in a relational table. Each object is uniquely mapped to a row in the table Object Identifier Pattern assign an OID to each record and object i.e. We augment the attributes with a new attribute that we refer to as the OID

Fall 2009ACS-3913 R McFadyen16 Façade Persistence subsystem will have a Façade that provides access to its services façade Requesting a ProductSpecification with a specific OID The façade is implemented using Singleton

Fall 2009ACS-3913 R McFadyen17 Representing Relationships in Tables Representing Object Associations as Tables pattern one-to-one place an OID FK in one or both tables representing the objects in the association or, create an associative table that records the OIDs of each object in the association or, could merge the two classes into one table Consider StoreRegister houses 11

Fall 2009ACS-3913 R McFadyen18 Representing Relationships in Tables Representing Object Associations as Tables pattern one-to-many create an associative table that records the OIDs of each object in relationship or, could use a Foreign Key on the Many side Consider ProductCatalogProductSpecification contains 11..*

Fall 2009ACS-3913 R McFadyen19 Representing Relationships in Tables Representing Object Associations as Tables pattern many-to-many create an associative table that records the OIDs of each object in relationship CompanyPerson employs **

Fall 2009ACS-3913 R McFadyen20 Representing Relationships in Tables Representing Object Associations as Tables pattern many-to-many AND with an Association Class create an associative table that records the OIDs of each object in relationship and attributes of the association class CompanyPerson employs ** Employment

Fall 2009ACS-3913 R McFadyen21 Representing Relationships in Tables Representing Object Associations as Tables pattern many-to-many AND with an Association Class create an associative table that records the OIDs of each object in relationship... Person marries * * Marriage

Fall 2009ACS-3913 R McFadyen22 Representing Relationships in Tables Representing Object Associations as Tables pattern Aggregation and Composition SaleSalesLineItem contains 1..* ProgrammeCourse contains 1..* * Treat as 1-to-many and many-to-many associations (Aside: Note that relational integrity rules/triggers may need to be defined.)

Fall 2009ACS-3913 R McFadyen23 Representing Relationships in Tables Representing Object Associations as Tables pattern Superclass/Subclass Payment CreditPaymentCashPaymentChequePayment 3 basic choices: all classes represented as separate tables, only the ‘leaf’ classes, or one table for all Others are possible (see ACS-3902)

Fall 2009ACS-3913 R McFadyen24 OR Mapping - Example When we map this structure to a Relational Database, we are creating an object- to-relational mapping. We need to define the relational database schema and specify which class(es) map to which relation(s), and whether the associations are mapped to relations or to foreign keys. When specifying a relations include all attributes, the PK, FKs and what the FK references. Suppose we have the following class model: Program name type description Course name credit description * * Offering slot room contains * offer

Fall 2009ACS-3913 R McFadyen25 Example - recall patterns for O-R mappings O-R Mapping The Representing Objects as Tables pattern says that each class will be represented in the RDb by a separate table (relation). The Object Identifier pattern tells us that each table representing a class will have the OID as the PK. The Representing Object Associations as Tables pattern gives us several options: use an association table to represent the association (for 1-1 and 1-m) we can choose to use a Foreign Key for a 1-1 we can choose to merge the two classes into one table etc

Fall 2009ACS-3913 R McFadyen26 Example - mapping ClassMaps to Relation Program Course AssociationMaps to Relation/FKey containsTable: Contains offerFK in Offering (refers to Course) Offering O-R Mapping, for the given class model we could decide: Course Program

Fall 2009ACS-3913 R McFadyen27 Example - mapping Relational Schema Program Course Offering nametypedescription slotroom namecreditdescription Contains pOID oOID cOID pOID cOID Illustrates the structure of the relations Attributes PKs - underlined. FKs - indicated via dashed lines. cOID

Fall 2009ACS-3913 R McFadyen28 Example - mapping Table structure with some sample records Program Course nametypedescription C Programming3This course introduces … pOID yearR123 4-yearR Java Programming Systems Analysis namecreditdescriptioncOID A 3-year programme of studies in Business Computing