300 likes | 532 Views
Chapter 11. Object-Oriented DBMSs. Chapter 27, 28 & Appendix K in Textbook. Advanced Database Applications. Computer-Aided Design (CAD). Computer-Aided Manufacturing (CAM). Computer-Aided Software Engineering (CASE). Network Management Systems.
E N D
Chapter 11 Object-Oriented DBMSs Chapter 27, 28 & Appendix K in Textbook
Advanced Database Applications • Computer-Aided Design (CAD). • Computer-Aided Manufacturing (CAM). • Computer-Aided Software Engineering (CASE). • Network Management Systems. • Office Information Systems (OIS) and Multimedia Systems. • Digital Publishing. • Geographic Information Systems (GIS). • Interactive and Dynamic Web sites. • Other applications with complex and interrelated objects and procedural data.
Weaknesses of RDBMSs • Poor Representation of “Real World” Entities. • Semantic Overloading. • Poor Support for Integrity and Enterprise Constraints. • Homogeneous Data Structure. • Limited Operations. • Difficulty Handling Recursive Queries. • Impedance Mismatch. • Other Problems with RDBMSs: • Transactions are generally short-lived and concurrency control protocols not suited for long-lived transactions. • Schema changes are difficult. • RDBMSs are poor at navigational access.
Example - Recursive Query StaffNo StaffNo MangrSNo MangrsSNo S005 S004 S003 S002 S001 S004 S003 S002 S001 NULL S005 S004 S003 S002 S001 S005 S005 S005 S004 S004 S003 S004 S003 S002 S001 NULL S003 S002 S001 S002 S001 S001
What is an OODBMS ? • OODBMS (Object-oriented Database Management System): is a database with data stored in objects and collections NOT rows and tables. • Object Oriented Concepts: • Abstraction, encapsulation, and information hiding. • Objects and attributes. • Object identity. • Methods and messages. • Classes, subclasses, superclasses, and inheritance. • Overriding, Overloading, Polymorphism and Dynamic Binding.
OODBMS • Traditional DBS • Persistence • Sharing • Transactions • Concurrency Control • Recovery Control • Security • Integrity • Querying • Semantic Data Model • Generalization • Aggregation • OO Programming • OID • Encapsulation • Inheritance • Types & Classes • Methods • Complex objects • Polymorphism • Extensibility • Special Requirements • Versioning • Schema Evolution OODBMS
Abstraction Abstraction is the process of identifying essential aspects of an entity and ignoring unimportant properties. Concentrate on what an object is and what it does, before deciding how to implement it.
Encapsulation & Information Hiding Encapsulation: means that an object contains both data structure and set of operations used to manipulate it. Information Hiding: meansseparating external aspects of an object from its internal details, which are hidden from outside. • Allows internal details of an object to be changed without affecting applications that use it, provided external details remain same. • Provides data independence.
Objects Object is a uniquely identifiable entity that contains both: • the attributes that describe the state of a real-world object, • and the actions associated with it. Definition very similar to that of an entity, however, Object encapsulates both state and behavior; an entity only models state. Persistent Objects vs. Transient Objects: • Transient: object’s memory allocated and deallocated by programming language’s runtime system. • Persistent: object’s storage managed by OODBMS.
Attributes Attributes contain current state of an object: • Attributes can be classified as simple or complex. • Simple attribute can be a primitive type such as integer, string, etc., which takes on literal values. • Complex attribute can contain collections and/or references. • Reference attribute represents relationship. • An object that contains one or more complex attributes is called a complex object.
Object Identity (OID) Object identifier (OID) assigned to object when it is created that is: • System-generated. • Unique to that object. • Invariant. • Independent of the values of its attributes (that is, its state). • Invisible to the user (ideally).
Object Identity (OID) In RDBMS, entity identity is value-based: primary key is used to provide uniqueness. Primary keys do not provide type of object identity required in OO systems: • key only unique within a relation, not across entire system; • key generally chosen from attributes of relation, making it dependent on entity state.
Methods & Messages Method: Defines behavior of an object, as a set of encapsulated functions. Message: Request from one object to another asking second object to execute one of its methods.
Object Showing Attributes & Methods Method 1 Method 2 Attributes Method 4 Method 3
Classes Classes are blueprints for defining a set of similar objects. • Objects in a class are called instances. • Class is also an object with own class attributes and class methods. • Object created from the same class share the same class attributes and methods.
Class Instance Share Attributes & Methods BranchNo = B005 Street = 22 Deer Rd City = London Postcode = SW1 4EH BRANCH Attributes branchNo street city postcode BranchNo = B007 Street = 16 Argyll St City = Aberdeen Postcode = AB2 3SU Methods print() getPostCode() numberOfStaff() BranchNo = B003 Street = 163 Main St City = Glasgow Postcode = G11 9QX
Subclasses, Superclasses, & Inheritance Inheritanceallows one class of objects to be defined as a special case of a more general class. • Special cases are subclasses and more general cases are superclasses. • Process of forming a superclass is generalization; forming a subclass is specialization. • Subclassinherits all properties of its superclass and can define its own unique properties. • Subclass can redefine inherited methods (overriding). • Relationship between subclass and superclass known as A KIND OF (AKO) relationship.
Subclasses, Superclasses, & Inheritance Types of inheritance: single, multiple, and repeated. Single Inheritance Multiple Inheritance Repeated Inheritance
Overriding, Overloading & Polymorphism Overriding is the process of redefining a property within a subclass. Overloading allows name of a method to be reused with a class or across classes. Polymorphism means ‘many forms’. Three types: operation, inclusion, and parametric. The process of selecting the appropriate method based on an object’s type is called binding. • If the determination of an object’s type can be deferred until runtime (rather than compile time), the selection is called dynamic binding.
Complex Objects A Complex object is something that can be viewed as a single object in the real world but it actually consists of many sub-objects. Two types of complex objects: • Unstructured complex objects: • Their structure hard to determine. • Requires a large amount of storage. • BLOB (Binary Large Objects): images & long test strings. • Structured complex objects: • Clear structure. • Sub-objects in A Part-Of (APO) relationship.
Structured Complex Objects The contained object can be handled in one of two ways: • Contained object can be encapsulated within complex object, accessed by complex object’s methods. • Or have its own independent existence, and only an OID is stored in complex object. Obj 1 M1 M2 Obj 2 M4 M3 Obj 3 Obj 1 M1 M2 M1 M2 OID 2 OID 2 Obj 2 M4 M4 M3 M3
Collections Contains a number of unnamed,homogeneous elements; each can be instance of atomic type, another collection, or a literal type. Types of Constructors: Set: unordered collection of objects without duplicates. Bag: unordered collection of objects that allows duplicates. List: ordered collection of objects that allows duplicates. Array: ordered collection of objects without duplicates. Dictionary: unordered sequence of key-value pairs without duplicate keys.
Commercial OODBMSs • GemStone from Gemstone Systems Inc., • Itasca from Ibex Knowledge Systems SA, • Objectivity/DB from Objectivity Inc., • ObjectStore from eXcelon Corp., • Ontos from Ontos Inc., • Poet from Poet Software Corp., • Jasmine from Computer Associates/Fujitsu, • Versant from Versant Object Technology.
Object Data Management Group (ODMG)www.odmg.org ODMG is an international consortium founded to address object standards. Major components of ODMG architecture for an OODBMS are: • Unified Modeling Language (UML). • Object Model (OM). • Object Definition Language (ODL). • Object Query Language (OQL). • C++, Smalltalk, and Java Language Binding.
BRANCH branchNo street city postcode print() getPostCode() numberOfStaff() Unified Modeling Language (UML) UML is a standard language for specifying, constructing, visualizing, and documenting the artifacts of a software system. • Include many structural diagrams (Class, Object diagrams…) and behavioral diagrams (UseCase, Sequence diagrams…). • Used to model objects and object relationships. Class Name MANAGER PROPERTY Association StaffNo sex DOB salary increasesalary() PropertyNo street city postcode rooms type 1..1 manage 1.1 1..1 offer 1.* Attribute offered-by Method
Unified Modeling Language (UML) PERSON Name FName LName CLIENT STAFF POWNER ClientNo telNO prefType MaxRent OwnerNo address StaffNo position DOB salary 1 OwnedBy N Owns ViewedBy Views M M PROPERTY MANAGER SALESTAFF PropertyNo rooms rent M 1 M WorksAt Has 1 1 1 BRANCH Offers Manages ManagedBy IsOfferedBy BranchNo address
Object Model (OM) Object Model (OM) provides the data type, type constructors& other concepts utilized in the ODL to specify the object schema. • Basic building blocks are object and literal. • Only an object has a unique identifier and state (current value). • Literal is a constant values. e.g. “Ahmed”, “123 Main St, London” . • Behavior defined by set of operations that can be performed on or by object. • State defined by values objects carry for a set of attributes of object or relationships between object and one or more other objects.
Object Definition Language (ODL) Object Definition Language (ODL) is a language for defining the specification of object types for OODBMS. e.g. of ODL definition for DreamHome: moduleDreamHome { Class Branch (extentbranchOfficeskeybranchNo) { attribute string branchNo; attributestructBranchAddress {string street, string city, string postcode} address; relationship Manager ManagedByinverse Manager::Manages; relationship set<SalesStaff> Has inverse SalesStaff::WorksAt; relationship set<PropertyForRent> Offers inverse PropertyForRent::IsOfferedBy; void takeOnPropertyForRent(in string propertyNo) raises(propertyAlreadyForRent); }; };
Object Query Language (OQL) Object Query Language OQL is a query language for OODBMS. • Does not provide explicit update operators - leaves this to operations defined on object types. OQL can be used for both associative and navigational access: • Associative query returns collection of objects (like SQL). • Navigational query accesses individual objects and object relationships used to navigate from one object to another.
Object Query Language (OQL) OQL vs. SQL A Simple Example: List the names of the children of employees working in the sales department. OQL SQL select c.fname, c.lname from Department d, d.Employee e, e.Children c where d.name = “Sales”; select c.fname, c.lname from Department d, Employee e, Children c where d.name = “Sales” and d.deptID = e.deptID and c.parentID = e.empID;