In this Lecture you will Learn: Data Management Design. Transient Object. Persistence Object

Similar documents
XXI. Object-Oriented Database Design

1 File Processing Systems

Object Oriented Database Management System for Decision Support System.

CACHÉ: FLEXIBLE, HIGH-PERFORMANCE PERSISTENCE FOR JAVA APPLICATIONS

Object Oriented Databases. OOAD Fall 2012 Arjun Gopalakrishna Bhavya Udayashankar

Foundations of Business Intelligence: Databases and Information Management

Object-persistence formats. Files. Object-oriented databases. Data management layer design. Relational databases. Relational Database Example.

æ A collection of interrelated and persistent data èusually referred to as the database èdbèè.

Chapter 6 FOUNDATIONS OF BUSINESS INTELLIGENCE: DATABASES AND INFORMATION MANAGEMENT Learning Objectives

Overview of Data Management

Course MIS. Foundations of Business Intelligence

Databases What the Specification Says

What is Data Virtualization? Rick F. van der Lans, R20/Consultancy

Chapter 1: Introduction. Database Management System (DBMS) University Database Example

Introduction. Introduction: Database management system. Introduction: DBS concepts & architecture. Introduction: DBS versus File system

DATABASE SYSTEM CONCEPTS AND ARCHITECTURE CHAPTER 2

Introduction: Database management system

Database Systems. National Chiao Tung University Chun-Jen Tsai 05/30/2012

SCHEMAS AND STATE OF THE DATABASE

Chapter 6: Physical Database Design and Performance. Database Development Process. Physical Design Process. Physical Database Design

Concepts of Database Management Seventh Edition. Chapter 9 Database Management Approaches

Chapter 1: Introduction

Physical Database Design and Tuning

5.5 Copyright 2011 Pearson Education, Inc. publishing as Prentice Hall. Figure 5-2

1. Physical Database Design in Relational Databases (1)

Chapter 3. Database Environment - Objectives. Multi-user DBMS Architectures. Teleprocessing. File-Server

1. INTRODUCTION TO RDBMS

Topics. Introduction to Database Management System. What Is a DBMS? DBMS Types

Foundations of Business Intelligence: Databases and Information Management

Overview of Database Management

TIM 50 - Business Information Systems

Lesson 8: Introduction to Databases E-R Data Modeling

12 File and Database Concepts 13 File and Database Concepts A many-to-many relationship means that one record in a particular record type can be relat

DBMS Questions. 3.) For which two constraints are indexes created when the constraint is added?

Foundations of Business Intelligence: Databases and Information Management

Raima Database Manager Version 14.0 In-memory Database Engine

Data Modeling Basics

10. Creating and Maintaining Geographic Databases. Learning objectives. Keywords and concepts. Overview. Definitions

Introduction to Object-Oriented and Object-Relational Database Systems

CS2Bh: Current Technologies. Introduction to XML and Relational Databases. Introduction to Databases. Why databases? Why not use XML?

CSE 132A. Database Systems Principles

Database System Concepts

Chapter 4. Architecture. Table of Contents. J2EE Technology Application Servers. Application Models

What is a database? COSC 304 Introduction to Database Systems. Database Introduction. Example Problem. Databases in the Real-World

Introduction to Databases

OBJECTS AND DATABASES. CS121: Introduction to Relational Database Systems Fall 2015 Lecture 21

Complex Data and Object-Oriented. Databases

DATABASE MANAGEMENT SYSTEM

Database System Architecture & System Catalog Instructor: Mourad Benchikh Text Books: Elmasri & Navathe Chap. 17 Silberschatz & Korth Chap.

Object Oriented Databases (OODBs) Relational and OO data models. Advantages and Disadvantages of OO as compared with relational

Physical Data Organization

Week 1 Part 1: An Introduction to Database Systems. Databases and DBMSs. Why Use a DBMS? Why Study Databases??

Database Management Systems. Chapter 1

What is Data Virtualization?

Chapter 2. Data Model. Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel

Principles of Database. Management: Summary

In this Lecture you will Learn: Systems Development Methodologies. Why Methodology? Why Methodology?

Introduction to Database Systems. Chapter 1 Introduction. Chapter 1 Introduction

Physical Database Design Process. Physical Database Design Process. Major Inputs to Physical Database. Components of Physical Database Design

DATABASE MANAGEMENT SYSTEMS. Question Bank:

Foundations of Business Intelligence: Databases and Information Management

Databases and Information Management

INTRODUCTION TO DATABASE SYSTEMS


MA-WA1920: Enterprise iphone and ipad Programming

Object-Oriented Databases Course Review

Distributed Objects and Components

A. TRUE-FALSE: GROUP 2 PRACTICE EXAMPLES FOR THE REVIEW QUIZ:

Databases and BigData

2. Background on Data Management. Aspects of Data Management and an Overview of Solutions used in Engineering Applications

The Entity-Relationship Model

Database Systems. Lecture 1: Introduction

CSE 233. Database System Overview

U III 5. networks & operating system o Several competing DOC standards OMG s CORBA, OpenDoc & Microsoft s ActiveX / DCOM. Object request broker (ORB)

Relational Database Basics Review

Intellicus Cluster and Load Balancing (Windows) Version: 7.3

CHAPTER 6 DATABASE MANAGEMENT SYSTEMS. Learning Objectives

File System Management

Gentran Integration Suite. Archiving and Purging. Version 4.2

How To Set Up An Intellicus Cluster And Load Balancing On Ubuntu (Windows) With A Cluster And Report Server (Windows And Ubuntu) On A Server (Amd64) On An Ubuntu Server

n Assignment 4 n Due Thursday 2/19 n Business paper draft n Due Tuesday 2/24 n Database Assignment 2 posted n Due Thursday 2/26

ECS 165A: Introduction to Database Systems

Overview RDBMS-ORDBMS- OODBMS

Case studies: Outline. Requirement Engineering. Case Study: Automated Banking System. UML and Case Studies ITNP090 - Object Oriented Software Design

Core Syllabus. Version 2.6 B BUILD KNOWLEDGE AREA: DEVELOPMENT AND IMPLEMENTATION OF INFORMATION SYSTEMS. June 2006

Introduction to Database Systems. Module 1, Lecture 1. Instructor: Raghu Ramakrishnan UW-Madison

Alexander Nikov. 5. Database Systems and Managing Data Resources. Learning Objectives. RR Donnelley Tries to Master Its Data

Dr. Pat Mirenda. Software Design Specification Document

Chapter 11: File System Implementation. Operating System Concepts with Java 8 th Edition

Database as a Service (DaaS) Version 1.02

Two Parts. Filesystem Interface. Filesystem design. Interface the user sees. Implementing the interface

Java EE 7: Back-End Server Application Development

Listeners. Formats. Free Form. Formatted

Introduction to Database Systems

Requirements Design Implementation. Software Architectures. Components Software Component Architecture. DSSA: Domain-Specific Software Architectures

COIS Databases

Chapter 1 File Organization 1.0 OBJECTIVES 1.1 INTRODUCTION 1.2 STORAGE DEVICES CHARACTERISTICS

Tivoli Storage Manager Explained

Transcription:

In this Lecture you will Learn: Data Management Design Chapter 18 The different ways of storing persistent objects The differences between object and relational databases How to design data management objects How to extend sequence diagrams to include data management objects M8748 Peter Lo 2007 1 M8748 Peter Lo 2007 2 Transient Object Some objects are Transient, exist in memory and are discarded when an application terminates. It called Transient Object. Examples of transient objects include instances of boundary and control classes and the objects used in applications like on-screen calculators. Persistence Object Some objects must exist from one execution of an application to another or be shared among different instances of applications. Such objects are Persistent Objects. Example of persistent objects include the books, borrowers and loans in a library system. A loan of a book to a borrower may be created on one occasion on one machine, and is accessed from another machine on another occasion, for example to send out overdue book reminders. M8748 Peter Lo 2007 3 M8748 Peter Lo 2007 4

Persistence Mechanisms Persistence Architecture Files hold data, typically on magnetic media such as disks and tapes Database Management Systems (DBMS) hold tables of data (relational DBMS) or objects (object DBMS) DBMS use files to store data or objects, but they hide the physical processes for storing data beneath a layer of abstraction Objects can also be serialized directly to files The choice of the architecture for persistence is a system design issue. The design of storage for specific classes and associations within the framework of that architecture is a class design issue. The overall design may be constrained by having to operate with existing systems or using existing DBMS M8748 Peter Lo 2007 5 M8748 Peter Lo 2007 6 Persistence Design Questions File Systems and Record Structure For the architect designing the persistent storage of a system there are a number of questions to be answered. Can files be used for some storage? Is it truly an OO system or just an interface to a relational database using Java or C++? Will the system use an existing DBMS? Will it use a relational DBMS? Will it use an object DBMS? What is the logical layering of the system? What is the physical layering of the system? Is the system distributed? Does this include distributed data storage? What protocols will be used to communicate within the system? Record in files can take different form: Fixed Length Variable Length Header and Detail Tagged Data M8748 Peter Lo 2007 7 M8748 Peter Lo 2007 8

File Systems and Record Structure Fixed Length (Padded) Easy to process, but wastes storage File Systems and Record Structure Variable Length (Delimited) More difficult to process (looking for delimiters), but saves storage space 12345678901234567890123456789012345 Simon Bennett Leice ster GB 21322012002 Simon, Bennett, Leicester, GB, 213, 22-01-2002 M8748 Peter Lo 2007 9 M8748 Peter Lo 2007 10 File Systems and Record Structure Header and Detail Allows for structure in data, may need line type and line no. File Systems and Record Structure Tagged Data (XML) Self-describing, but storage overhead for tags. 1, Simon, Bennett 2,1, 0077098641,2002 2,2, 0077096738,2001 <Author> <Forename>Simon</Forename> <Surname>Bennett</Surname> </Author> M8748 Peter Lo 2007 11 M8748 Peter Lo 2007 12

File Organization in File Systems Serial New records appended Sequential Records ordered in file, usually according to a numeric key Random Uses an algorithm to convert a key to an address in the file File Access Methods in File Systems Serial To read serial and sequential files Index-sequential Using indexes to find records in a sequential file and improve access time Direct Using relative or hashed addressing to move directly to the required record in the file M8748 Peter Lo 2007 13 M8748 Peter Lo 2007 14 Example: Searching for Hamer using Index-sequential File Access Explanation In order to look for the record for Hamer Search the Master Index until you reach a key that is greater than Hamer (in string comparison terms). Go to the Block Index for that key (2). Search the Block Index until you reach a key that is greater than Hamer (in string comparison terms). Goto the Block for that key. Search through the block until you find the right record with the required key. (If you get to the end of the block without finding the record then it doesn t already exist.) M8748 Peter Lo 2007 15 M8748 Peter Lo 2007 16

Direct Access Improving Access Creating a linked list in random files to make it possible to read records in sequential order Adding a secondary index keyed on a field that is not the key on which the main access method is based Indexes can be inverted files or use other techniques such as B-trees M8748 Peter Lo 2007 17 M8748 Peter Lo 2007 18 File Types File Using Example Master Files Stores relatively permanent data about an entity Transaction Files Stores records that contain day-to-day business and operational data Index Files Temporary File or Work Files It is a temporary file created for a single task Backup Files A compressed version of the original file and its locations created by Backup Parameter Files M8748 Peter Lo 2007 19 Using files in Java to handle localization of prompts and messages Use the java.util.locale class to hold information about the current locale language_country_variant fr_fr_euro fr_ca en_uk en_au M8748 Peter Lo 2007 20

File Using Example The Java class java.util.resourcebundle uses the locale to load a file with locale-specific values. E.g. UIResources_fr_FR_EURO Java code to use this: resources = ResourceBundle.getBundle( UIResources, currentlocale); Button cancelbutton = new Button(resources.getString( Cancel ); Resource File File for French is UIResources_fr_FR_EURO It Contains Cancel = Annuler OK = OK File = Fichier M8748 Peter Lo 2007 21 M8748 Peter Lo 2007 22 Problems with Files Redundancy Number of files grows with applications, and data is duplicated Inconsistence Data is updated in one application s files, but not in another s Maintenance Problems Changes to data structures mean changes to many programs Difficulty Combining Data Business needs may mean users want data from different applications Database Management System (DBMS) Corporate database consolidates data for different applications Each application then has its own view of a subset of the data Application 1 Application 2 Database M8748 Peter Lo 2007 23 M8748 Peter Lo 2007 24

DBMS Schema The Three Levels Architecture Ultimately data in databases is stored in files, but their structure is hidden from developers END USERS EXTERNAL LEVEL EXTERNAL VIEW EXTERNAL VIEW external/conceptual mapping CONCEPTUAL LEVEL INTERNAL LEVEL CONCEPTUAL SCHEMA conceptual/internal mapping INTERNAL SCHEMA STORED DATABASE M8748 Peter Lo 2007 25 M8748 Peter Lo 2007 26 DBMS Features Data Definition Language (DDL) Data Manipulation Language (DML) Integrity Constraints Transaction Management Concurrency Security Tuning of Storage Advantages of DBMS Eliminate unnecessary duplication of data Enforce data integrity through constraints Changes to conceptual schema need not affect external schema Changes to internal schema need not affect the conceptual schema Many tools are available to manage the database M8748 Peter Lo 2007 27 M8748 Peter Lo 2007 28

Disadvantages of DBMS Cost of investing in the DBMS Running cost, including staff (Database Administrators) to manage the DBMS Processing overhead in converting data to format required by programs Types of DBMS: Relational Represent data in tables Tables consist of rows of data organized in columns M8748 Peter Lo 2007 29 M8748 Peter Lo 2007 30 Types of DBMS: Object Store objects as objects Designed to handle complex nested objects for graphical and multimedia applications Types of DBMS: Object-Relational Hybrid databases that can store data in tables but can also store objects in tables M8748 Peter Lo 2007 31 M8748 Peter Lo 2007 32

Relational DBMS To store objects in a relational database, the objects have to be flattened into tables Complex objects have to be taken apart and the parts stored in different tables When retrieved from the database, the object has to be reassembled from the parts in different tables Normalization Data from complex structures is flattened into tables Typically normalization is carried out as far as Third Normal Form In an object-oriented system, we may use normalization to convert classes to table schemas M8748 Peter Lo 2007 33 M8748 Peter Lo 2007 34 Normalization Example Normalization Example: Objects as a Table To get to First Normal Form, break out the repeating groups M8748 Peter Lo 2007 35 M8748 Peter Lo 2007 36

Normalization Example: First Normal Form Normalization Example: Second Normal Form M8748 Peter Lo 2007 37 M8748 Peter Lo 2007 38 Normalization Example: Third Normal Form Alternative Approach Classes with simple data structure become tables Object ID become primary keys Where classes contain another class as an attribute create a table for the embedded class For collections create two tables, one for the objects in the collection, the other to hold Object ID of the containing objects and the contained objects M8748 Peter Lo 2007 39 M8748 Peter Lo 2007 40

Alternative Approach for Association One-to-Many Associations can be treated like collections Many-to-Many Associations become two separate tables for the objects and a table to hold pairs of Object ID One-to-One Associations are implemented as foreign-key attributes each class gains an extra attribute for the Object ID of the other Alternative Approach to Implement Inheritance Only implement the superclass as a table including all subclass attributes Only implement the subclasses as tables, duplicating superclass attributes in each Implement superclass and subclasses as tables with shared primary keys Each approach has Disadvantages M8748 Peter Lo 2007 41 M8748 Peter Lo 2007 42 Object DBMS Sample C++ ObjectStore Operation ODBMS have the advantage that objects can be stored directly Based on the Object Data Management Group (ODMG) standard Not all object databases conform to the standard Object databases are closely linked to programming languages with ways of navigating through the database Some will transparently materialize objects from the database when they are referred to Update transactions need to be bracketed with start and finish transaction methods Operations are still implemented in object-oriented languages M8748 Peter Lo 2007 43 IntCampaign * CreativeStaff::findIntCampaign( string campaigncode ) { IntCampaign * intcampaignpointer; intcampaignpointer = staffintcampaignlist.getvalue().query_pick( IntCampaign*, campaigncode == this->campaigncode, os_database::of(this)); return intcampaignpointer; } M8748 Peter Lo 2007 44

Distributed Databases Designing Data Management Classes Organizations that need to decentralize their computer processing may also need to decentralized their database. When computing databases are scattered rather than centralized, they are called Distributed Database Systems. Alternatives: Add save and retrieve operations to classes Make save and retrieve class-scope methods Allow all persistent objects to inherit from a PersistentObject superclass Use collection classes to manage persistence Use broker classes to manage persistence Use a parameterized class to handle persistence for different classes M8748 Peter Lo 2007 45 M8748 Peter Lo 2007 46 PersistentObject Create an abstract superclass and make all persistent classes inherit from it PersistentObject Materialization as Class Method Sequence diagram for Get number of campaigns for location showing Location retrieving (or materializing) an instance M8748 Peter Lo 2007 47 M8748 Peter Lo 2007 48

Database Broker Use a broker class responsible for materializing instances of each class from the database Database Broker Materializes Instances Sequence diagram for Get number of Campaigns for Location showing LocationBroker retrieving an instance of Location M8748 Peter Lo 2007 49 M8748 Peter Lo 2007 50 Inheritance Hierarchy of Database Brokers Simplified version of inheritance hierarchy for database brokers. RelationalBroker and Other Classes RelationalBroker class and classes from other package M8748 Peter Lo 2007 51 M8748 Peter Lo 2007 52

Package Diagram Proxy Pattern Class diagram showing packages for database brokers package. Proxy objects act as placeholders for the real objects, e.g. IntCampaigns in Locations The IntCampaignProxy has the same interface as IntCampaign, but no data When a Location requires data about one of its IntCampaigns, it sends a message to the Proxy The Proxy requests the Broker to materialize the IntCampaign and passes the message on M8748 Peter Lo 2007 53 M8748 Peter Lo 2007 54 Proxy Pattern The Proxy can then replace the reference to itself in the Location with a reference to the real materialized object This approach can be combined with caching of objects The caches can be used by the Broker to check whether an object is already in memory and save materializing it from the database if it is Transaction Commit Cache Actions Six caches Cache actions New clean cache write to database New dirty cache write to database New deleted cache delete from cache Old clean cache delete from cache Old dirty cache write to database Old deleted cache delete from database M8748 Peter Lo 2007 55 M8748 Peter Lo 2007 56

Class Diagram with Caches and Proxies Extension of the database broker framework to include caches and proxies. Collaboration Diagram Collaboration diagram showing proxy, broker and cache objects collaborating to retrieve an object instance M8748 Peter Lo 2007 57 M8748 Peter Lo 2007 58 Explanation The Location sends the message gettitle() to the IntCampaignProxy. The IntCampaignProxy checks whether the IntCampaign is in memory. It is not, so it then requests the object by object identifier from the broker, IntCampaignBroker. The IntCampaignBroker checks if the object is in a Cache. It is not, so the IntCampaignBroker retrieves the object from the database and returns it to the IntCampaignProxy. The IntCampaignProxy sends the gettitle() message to the IntCampaign object and returns the result to the Location. Using a Framework Why develop a framework when you can use an existing one? Object-table mappings: Toplink & CocoBase Products that will map attributes of classes to columns in a relational database table J2EE Application Servers Enterprise JavaBeans (EJB) can be used Entity Beans for business objects Container-Managed Persistence (CMP) is a framework for J2EE containers to handle the persistence of instances of entity beans Use J2EE Patterns M8748 Peter Lo 2007 59 M8748 Peter Lo 2007 60