Data Management Design G.Ramesh Babu. In This Lecture You Will Learn: n The different ways of storing persistent objects n The differences between object.

Slides:



Advertisements
Similar presentations
Chapter 10: Designing Databases
Advertisements

Physical DataBase Design
Technology Guide 3 Data and Database T3-1. IT for Management Prof. Efraim Turban T3-2 File Management Hierarchy of data for a computer-based file Record.
Management Information Systems, Sixth Edition
1 Chapter 2 Database Environment Transparencies © Pearson Education Limited 1995, 2005.
File System Implementation
Chapter 3 Database Management
Data Management Design
Organizing Data & Information
Ch1: File Systems and Databases Hachim Haddouti
11 3 / 12 CHAPTER Databases MIS105 Lec14 Irfan Ahmed Ilyas.
Introduction to Databases Transparencies
Physical design. Stage 6 - Physical Design Retrieve the target physical environment Create physical data design Create function component implementation.
Chapter 11 Data Management Layer Design
Chapter 4: Database Management. Databases Before the Use of Computers Data kept in books, ledgers, card files, folders, and file cabinets Long response.
“DOK 322 DBMS” Y.T. Database Design Hacettepe University Department of Information Management DOK 322: Database Management Systems.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
Mgt 20600: IT Management & Applications Databases Tuesday April 4, 2006.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
Introduction to Databases Transparencies 1. ©Pearson Education 2009 Objectives Common uses of database systems. Meaning of the term database. Meaning.
DATABASE MANAGEMENT SYSTEM ARCHITECTURE
IST Databases and DBMSs Todd S. Bacastow January 2005.
Database System Concepts and Architecture Lecture # 3 22 June 2012 National University of Computer and Emerging Sciences.
Information storage: Introduction of database 10/7/2004 Xiangming Mu.
ASP.NET Programming with C# and SQL Server First Edition
Web-Enabled Decision Support Systems
CSC271 Database Systems Lecture # 4.
CST203-2 Database Management Systems Lecture 2. One Tier Architecture Eg: In this scenario, a workgroup database is stored in a shared location on a single.
1 Introduction to Database Systems. 2 Database and Database System / A database is a shared collection of logically related data designed to meet the.
Data and its manifestations. Storage and Retrieval techniques.
Lecture2: Database Environment Prepared by L. Nouf Almujally & Aisha AlArfaj 1 Ref. Chapter2 College of Computer and Information Sciences - Information.
Ch. 1 데이터베이스시스템 (2). Ch.1 Database System 데이터베이스시스템 2 What to Learn Database System Overview Entity-Relationship diagram Relational Data Model  Structure.
Object Persistence Design Chapter 13. Key Definitions Object persistence involves the selection of a storage format and optimization for performance.
Chapter 12: Designing Databases
2Object-Oriented Analysis and Design with the Unified Process Objectives  Describe the differences and similarities between relational and object-oriented.
5-1 McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies, Inc. All rights reserved.
 Three-Schema Architecture Three-Schema Architecture  Internal Level Internal Level  Conceptual Level Conceptual Level  External Level External Level.
Lecture2: Database Environment Prepared by L. Nouf Almujally 1 Ref. Chapter2 Lecture2.
Hibernate Persistence. What is Persistence Persist data to database or other storage.  In OO world, persistence means persist object to external storage.
Lecture # 3 & 4 Chapter # 2 Database System Concepts and Architecture Muhammad Emran Database Systems 1.
5 - 1 Copyright © 2006, The McGraw-Hill Companies, Inc. All rights reserved.
DataBase Management System What is DBMS Purpose of DBMS Data Abstraction Data Definition Language Data Manipulation Language Data Models Data Keys Relationships.
INFORMATION MANAGEMENT Unit 2 SO 4 Explain the advantages of using a database approach compared to using traditional file processing; Advantages including.
Chapter 38 Persistence Framework with Patterns 1CS6359 Fall 2011 John Cole.
Introduction to Database Systems1. 2 Basic Definitions Mini-world Some part of the real world about which data is stored in a database. Data Known facts.
MANAGING DATA RESOURCES ~ pertemuan 7 ~ Oleh: Ir. Abdul Hayat, MTI.
1 CS 430 Database Theory Winter 2005 Lecture 2: General Concepts.
INFO1408 Database Design Concepts Week 15: Introduction to Database Management Systems.
Chapter 9 Database Systems Introduction to CS 1 st Semester, 2014 Sanghyun Park.
Data resource management
DATABASE MANAGEMENT SYSTEM ARCHITECTURE
1 Chapter 1 Introduction to Databases Transparencies.
GLOBEX INFOTEK Copyright © 2013 Dr. Emelda Ntinglet-DavisSYSTEMS ANALYSIS AND DESIGN METHODSINTRODUCTORY SESSION EFFECTIVE DATABASE DESIGN for BEGINNERS.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition File System Implementation.
Database Systems Lecture 1. In this Lecture Course Information Databases and Database Systems Some History The Relational Model.
Physical Database Design Purpose- translate the logical description of data into the technical specifications for storing and retrieving data Goal - create.
CSE323 การวิเคราะห์และออกแบบระบบ (Systems Analysis and Design) Lecture 12: Data Management Design.
Object storage and object interoperability
FILE ORGANIZATION.
Java Programming: Advanced Topics 1 Enterprise JavaBeans Chapter 14.
Chapter 2 Database Environment.
Presentation on Database management Submitted To: Prof: Rutvi Sarang Submitted By: Dharmishtha A. Baria Roll:No:1(sem-3)
1 10 Systems Analysis and Design in a Changing World, 2 nd Edition, Satzinger, Jackson, & Burd Chapter 10 Designing Databases.
Management Information Systems by Prof. Park Kyung-Hye Chapter 7 (8th Week) Databases and Data Warehouses 07.
Databases and DBMSs Todd S. Bacastow January
Databases and DBMSs Todd S. Bacastow January 2005.
Database Management System
File System Implementation
Data, Databases, and DBMSs
Database Environment Transparencies
Presentation transcript:

Data Management Design G.Ramesh Babu

In This Lecture You Will Learn: n The different ways of storing persistent objects n The differences between object and relational databases n How to design data management objects n How to extend sequence diagrams to include data management objects

Persistence n Some objects are transient, exist in memory and are discarded when an application terminates n 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

Persistence Mechanisms n Files hold data, typically on magnetic media such as disks and tapes n Database management systems (DBMS) hold tables of data (relational DBMS) or objects (object DBMS) n DBMS use files to store data or objects, but they hide the physical processes for storing data beneath a layer of abstraction n Objects can also be serialized directly to files

Persistence Architecture n The choice of the architecture for persistence is a system design issue n The design of storage for specific classes and associations within the framework of that architecture is a class design issue n The overall design may be constrained by having to operate with existing systems or using existing DBMS

Persistence Design Questions n Can files be used for some storage? n Is it truly an O-O system or just an interface to a relational database using Java or C++? n Will the system use an existing DBMS? n Will it use a relational DBMS? n Will it use an object DBMS?

Persistence Design Questions n What is the logical layering of the system? n What is the physical layering of the system? n Is the system distributed? Does this include distributed data storage? n What protocols will be used to communicate within the system?

File Systems Files and record structures n Fixed length (padded) n Variable length (delimited) n Header and detail n Tagged data (XML) Simon Bennett Leice ster GB ”Simon”,”Bennett”,”Leicester”,”GB”,2 13,” ” 1,”Simon”,”Bennett” 2,1,” ”,2002 2,2,” ”,2001 Simon Bennett

File Systems File organization n Serial—new records appended n Sequential—records ordered in file, usually according to a numeric key n Random—uses an algorithm to convert a key to an address in the file

File Systems File access methods n Serial—to read serial and sequential files n Index-sequential—using indexes to find records in a sequential file and improve access time n Direct—using relative or hashed addressing to move directly to the required record in the file

Index-sequential Access Searching for Hamer using index-sequential file access

Direct Access

Improving Access n Creating a linked list in random files to make it possible to read records in sequential order n Adding a secondary index keyed on a field that is not the key on which the main access method is based n Indexes can be inverted files or use other techniques such as B-trees

File Types n Master files n Transaction files n Index files n Temporary file or work files n Backup files n Parameter files

File Example n Using files in Java to handle localization of prompts and messages n 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

File Example n The Java class java.util.ResourceBundle uses the locale to load a file with locale- specific values e.g. UIResources_fr_FR_EURO n Java code to use this: resources = ResourceBundle.getBundle(”UIResources”, currentLocale); Button cancelButton = new Button(resources.getString(”Cancel”); rather than Button cancelButton = new Button(”Cancel”);

Resource File n File for French is UIResources_fr_FR_EURO n Contains Cancel = Annuler OK = OK File = Fichier …

Database Management Systems (DBMS) n Problems with files: –redundancy—number of files grows with applications, and data is duplicated –inconsistency—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

DBMS n Corporate database consolidates data for different applications n Each application then has its own view of a subset of the data Database Application 1Application 2

DBMS Schema n Ultimately data in databases is stored in files, but their structure is hidden from developers Conceptual Schema External Schema Internal Schema The view on data used by application programs. The logical model of data that is separate from how it is used. The physical storage of data in files and indexes.

DBMS Features n Data Definition Language (DDL) n Data Manipulation Language (DML) n Integrity Constraints n Transaction Management n Concurrency n Security n Tuning of Storage

Advantages of DBMS n Eliminate unnecessary duplication of data n Enforce data integrity through constraints n Changes to conceptual schema need not affect external schema n Changes to internal schema need not affect the conceptual schema n Many tools are available to manage the database

Disadvantages of DBMS n Cost of investing in the DBMS n Running cost, including staff (Database Administrators) to manage the DBMS n Processing overhead in converting data to format required by programs

Types of DBMS n Relational—represent data in tables –tables consist of rows of data organized in columns

Types of DBMS n Object—store objects as objects –designed to handle complex nested objects for graphical and multimedia applications n Object-relational—hybrid databases that can store data in tables but can also store objects in tables

Relational DBMS n To store objects in a relational database, the objects have to be ‘flattened’ into tables n Complex objects have to be taken apart and the parts stored in different tables n When retrieved from the database, the object has to be reassembled from the parts in different tables

Normalization n Data from complex structures is ‘flattened’ into tables n Typically normalization is carried out as far as ‘Third Normal Form’ n In an object-oriented system, we may use normalization to convert classes to table schemas

Normalization Example

Objects as a Table n To get to First Normal Form, break out the repeating groups

First Normal Form

Second Normal Form

Third Normal Form

Alternative Approach n Classes with simple data structure become tables n Object IDs become primary keys n Where classes contain another class as an attribute create a table for the embedded class n For collections create two tables, one for the objects in the collection, the other to hold Object IDs of the containing objects and the contained objects

Alternative Approach n One-to-many associations can be treated like collections n Many-to-many associations become two separate tables for the objects and a table to hold pairs of Object IDs n 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 n 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 n Each approach has disadvantages

Object DBMS n ODBMS have the advantage that objects can be stored directly n Object Data Management Group (ODMG) standard n Not all object databases conform to the standard n Object databases are closely linked to programming languages with ways of navigating through the database

Sample C++ ObjectStore Operation IntCampaign * CreativeStaff::findIntCampaign ( string campaignCode ) { IntCampaign * intCampaignPointer; intCampaignPointer = staffIntCampaignList.getValue().query_pick( “IntCampaign*”, “campaignCode == this->campaignCode”, os_database::of(this)); return intCampaignPointer; }

Object DBMS n Some will transparently ‘materialize’ objects from the database when they are referred to n Update transactions need to be bracketed with start and finish transaction methods n Operations are still implemented in object-oriented languages

Designing Data Management Classes n Alternatives (two in bold are covered here): –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

PersistentObject n Create an abstract superclass and make all persistent classes inherit from it

PersistentObject Materialization as Class Method n Sequence diagram Location( locationCode, locationName, intCampaignList[ ]) GetNumberOf Campaigns( ) :ListCampaigns Dialog Location findByLocation Code (locCode) numberOfCampaigns( ) :Location Campaign Manager

Database Broker n Use a broker class responsible for materializing instances of each class from the database Location LocationBroker - instance: LocationBroker - LocationBroker( ) + instance( ): LocationBroker + findByLocationCode( String ): Location + iterateLocation( ): Location materializes

Database Broker Materializes Instances n Sequence diagram Location( locationCode, locationName, intCampaignList[ ]) GetNumberOf Campaigns( ) :ListCampaigns Dialog :LocationBroker findByLocation Code (locCode) numberOfCampaigns( ) :Location Campaign Manager

Inheritance Hierarchy of Database Brokers

RelationalBroker and Other Classes java::sql::Connection java::sql::ResultSet java:sql::Statement oracle::jdbc::driver::Oracle Driver RelationalBroker Location materializes LocationBroker

Package Diagram sun.jdbc java.sql Broker Framework «import» « Application Brokers

Proxy Pattern n Proxy objects act as placeholders for the real objects, e.g. IntCampaigns in Locations n The IntCampaignProxy has the same interface as IntCampaign, but no data n When a Location requires data about one of its IntCampaigns, it sends a message to the Proxy n The Proxy requests the Broker to materialize the IntCampaign and passes the message on

Proxy Pattern n The Proxy can then replace the reference to itself in the Location with a reference to the real materialized object n This approach can be combined with caching of objects n 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

Adding Caches n Six caches –new clean cache –new dirty cache –new deleted cache –old clean cache –old dirty cache –old deleted cache

Transaction Commit Cache Actions n Six caches –new clean cache –new dirty cache –new deleted cache –old clean cache –old dirty cache –old deleted cache n Cache actions –write to database –delete from cache –write to database –delete from database

Class Diagram with Caches and Proxies

Collaboration Diagram :IntCampaignBroker :IntCampaign :Cache :IntCampaignProxy :Location 1 printList( ) 1.1 getTitle( ) 1.2 inMemory( ) 1.3 [not in memory] getIntCampaign ( objectid ) 1.4 * inCache ( objectid ) 1.5 [not in cache] retrieveIntCampaign ( objectid ) 1.6 getTitle( )

Using a Framework n Why develop a framework when you can use an existing one? n Object-table mappings –Toplink –CocoBase n Products that will map attributes of classes to columns in a relational database table

Using a Framework n J2EE Application Servers n Enterprise JavaBeans (EJBs) can be used – Entity Beans for business objects n Container-Managed Persistence (CMP) is a framework for J2EE containers to handle the persistence of instances of entity beans n Use J2EE Patterns (Alur et al., 2001)

Summary In this lecture you have learned about: n The different ways of storing persistent objects n The differences between object and relational databases n How to design data management objects n How to extend sequence diagrams to include data management objects

References n Silberschatz et al. (1996) n Howe (2001) n Eaglestone and Ridley (1998) n Alur, Crupi and Malks (2001) (For full bibliographic details, see Bennett, McRobb and Farmer)