450 likes | 469 Views
Object-Oriented Database Development (Hoffer Chap 15). University of California, Berkeley School of Information Management and Systems SIMS 257: Database Management. Lecture Outline. Review Object Oriented DBMS Inverted File and Flat File DBMS Object-Relational DBMS (revisited)
E N D
Object-Oriented Database Development (Hoffer Chap 15) University of California, Berkeley School of Information Management and Systems SIMS 257: Database Management
Lecture Outline • Review • Object Oriented DBMS • Inverted File and Flat File DBMS • Object-Relational DBMS (revisited) • Intelligent DBMS • Object Oriented Database Development • Design using UML • Construction with ODL • Querying with OQL
Lecture Outline • Review • Object Oriented DBMS • Inverted File and Flat File DBMS • Object-Relational DBMS (revisited) • Intelligent DBMS • Object Oriented Database Development • Design using UML • Construction with ODL • Querying with OQL
Object-Oriented DBMS Basic Concepts • Each real-world entity is modeled by an object. Each object is associated with a unique identifier (sometimes call the object ID or OID)
Object-Oriented DBMS Basic Concepts • Each object has a set of instance attributes (or instance variables) and methods. • The value of an attribute can be an object or set of objects. Thus complex object can be constructed from aggregations of other objects. • The set of attributes of the object and the set of methods represent the object structure and behavior, respectively
Object-Oriented DBMS Basic Concepts • The attribute values of an object represent the object’s status. • Status is accessed or modified by sending messages to the object to invoke the corresponding methods
Object-Oriented DBMS Basic Concepts • Objects sharing the same structure and behavior are grouped into classes. • A class represents a template for a set of similar objects. • Each object is an instance of some class.
Object-Oriented DBMS Basic Concepts • A class can be defined as a specialization of of one or more classes. • A class defined as a specialization is called a subclass and inherits attributes and methods from its superclass(es).
Object-Oriented DBMS Basic Concepts • An OODBMS is a DBMS that directly supports a model based on the object-oriented paradigm. • Like any DBMS it must provide persistent storage for objects and their descriptions (schema). • The system must also provide a language for schema definition and and for manipulation of objects and their schema • It will usually include a query language, indexing capabilities, etc.
Generalization Hierarchy employee Employee No Name Address Date hired Date of Birth calculateAge Hourly Salaried consultant Hourly Rate Annual Salary Stock Option Contract No. Date Hired calculateWage calculateStockBenefit AllocateToContract
Inverted File DBMS • Usually similar to Hierarchic DBMS in record structure • Support for repeating groups of fields and multiple value fields • All access is via inverted file indexes to DBS specified fields. • Examples: ADABAS DBMS from Software AG -- used in the MELVYL system
Flat File DBMS • Data is stored as a simple file of records. • Records usually have a simple structure • May support indexing of fields in the records. • May also support scanning of the data • No mechanisms for relating data between files. • Usually easy to use and simple to set up
Object Relational Data Model • Class, instance, attribute, method, and integrity constraints • OID per instance • Encapsulation • Multiple inheritance hierarchy of classes • Class references via OID object references • Set-Valued attributes • Abstract Data Types
PostgreSQL Classes • The fundamental notion in Postgres is that of a class, which is a named collection of object instances. Each instance has the same collection of named attributes, and each attribute is of a specific type. Furthermore, each instance has a permanent object identifier (OID) that is unique throughout the installation. Because SQL syntax refers to tables, we will use the terms table and class interchangeably. Likewise, an SQL row is an instance and SQL columns are attributes.
Creating a Class • You can create a new class by specifying the class name, along with all attribute names and their types: CREATE TABLE weather ( city varchar(80), temp_lo int, -- low temperature temp_hi int, -- high temperature prcp real, -- precipitation date date );
Intelligent Database Systems • Intelligent DBS are intended to handle more than just data, and may be used in tasks involving large amounts of information where analysis and “discovery” are needed. The following is based on “Intelligent Databases” by Kamran Parsaye, Mark Chignell, Setrag Khoshafian and Harry Wong AI Expert, March 1990, v. 5 no. 3. Pp 38-47
Intelligent Database Systems • They represent the evolution and merging of several technologies: • Automatic Information Discovery • Hypermedia • Object Orientation • Expert Systems • Conventional DBMS
Intelligent Database Systems Automatic discovery Expert Systems Intelligent Databases Hypermedia Object Orientation Traditional Databases
Intelligent Databases • Intelligent Database Engine • OO support • Inference features • Global optimization • Rule manager • Explanation manager • Transaction manager • Metadata manager • Access module • Multimedia manager
Lecture Outline • Review • Object Oriented DBMS • Inverted File and Flat File DBMS • Object-Relational DBMS (revisited) • Intelligent DBMS • Object Oriented Database Development • Construction with ODL • Design using UML • Querying with OQL
Chapter 15:Object-Oriented Database Development Modern Database Management 6th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred R. McFadden This Lecture uses the slides following from www.prenhall.com/hoffer
Object Definition Language (ODL) • Corresponds to SQL’s DDL (Data Definition Language) • Specify the logical schema for an object-oriented database • Based on the specifications of Object Database Management Group (ODMG)
Defining a Class • class – keyword for defining classes • attribute – keyword for attributes • operations – return type, name, parameters in parentheses • relationship – keyword for establishing relationship
Defining an Attribute • Value can be either: • Object identifier OR Literal • Types of literals • Atomic – a constant that cannot be decomposed into components • Collection – multiple literals or object types • Structure – a fixed number of named elements, each of which could be a literal or object type • Attribute ranges • Allowable values for an attribute • enum – for enumerating the allowable values
Kinds of Collections • Set – unordered collection without duplicates • Bag – unordered collection that may contain duplicates • List – ordered collection, all the same type • Array – dynamically sized ordered collection, locatable by position • Dictionary – unordered sequence of key-value pairs without duplicates
Defining Structures Structure = user-defined type with components struct keyword Example: struct Address { String street_address String city; String state; String zip; };
Defining Operations • Return type • Name • Parentheses following the name • Arguments within the parentheses
Defining Relationships • Only unary and binary relationships allowed • Relationships are bi-directional • implemented through use of inverse keyword • ODL relationships are specified: • relationship indicates that class is on many-side • relationship set indicates that class is on one-side and other class (many) instances unordered • relationship list indicates that class is on one-side and other class (many) instances ordered
Figure 15-1 –UML class diagram for a university database The following slides illustrate the ODL implementation of this UML diagram
Figure 15-2 –ODL Schema for university database class keywordbegins the class definition.Class components enclosed between { and }
attribute has a data type and a name Figure 15-2 – ODL Schema for university database specify allowable values using enum
Figure 15-2 –ODL Schema for university database extent = the set of all instances of the class
Figure 15-2 –ODL Schema for university database Operation definition: return type, name, and argument list. Arguments include data types and names
relationship sets indicate 1:N relationship to an unordered collection of instances of the other class inverse establishes the bidirectionality of the relationship Figure 15-2 –ODL Schema for university database
relationship list indicates 1:N relationship to an ordered collection of instances of the other class Figure 15-2 –ODL Schema for university database
relationship indicates N:1 relationship to an instance of the other class Figure 15-2 –ODL Schema for university database
Figure 15-3 – UML class diagram for an employee project database (a) Many-to-many relationship with an association class Note: In order to capture special features of assignment, this should be converted into two 1:N relationships
Figure 15-3 – UML class diagram for an employee project database (b) Many-to many relationship broken into two one-to-many relationships class Employee { (extent employees key emp_id) …………. attribute set (string) skills_required; }; Note: key indicates indentifier (candidate key) Note: attribute set indicates a multivalued attribute
Figure 15-4 UML class diagram showing employee generalization class Employee extends Employee{ ( …………. …………. } Note: extends denotes subclassing
Note: abstract class denotes non-instantiable (complete constraint) abstract class Student extends Employee{ ( …………. abstract float calc_tuition(); } Note: abstract operationdenotes no method (no implementation) of calc_tuition at the Student level Figure 15-5 –UML class diagram showing student generalization
Creating Object Instances • Specify a tag that will be the object identifier • MBA699 course (); • Initializing attributes: • Cheryl student (name: “Cheryl Davis”, dateOfBirth:4/5/77); • Initializing multivalued attributes: • Dan employee (emp_id: 3678, name: “Dan Bellon”, skills {“Database design”, “OO Modeling”}); • Establishing links for relationship • Cheryl student (takes: {OOAD99F, Telecom99F, Java99F});
Querying Objects in the OODB • Object Query Language (OQL) • ODMG standard language • Similar to SQL-92 • Some differences: • Joins use class’s relationship name: • Select x.enrollment from courseofferings x, x.belongs_to y where y.crse_course = “MBA 664” and x.section = 1; • Using a set in a query • Select emp_id, name from employees where “Database Design” in skills;
Current ODBMS Products • Rising popularity due to: • CAD/CAM applications • Geographic information systems • Multimedia • Web-based applications • Increasingly complex data types • Applications of ODBMS • Bill-of-material • Telecommunications navigation • Health care • Engineering design • Finance and trading