Top Banner

of 38

OODB CONCEPT

Apr 10, 2018

Download

Documents

Quynh Khuong
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 8/8/2019 OODB CONCEPT

    1/38

    Object Oriented Databases

    Software Engineering Department

  • 8/8/2019 OODB CONCEPT

    2/38

    2

    Lecture outliney Object-Oriented concepts

    y Objects, Classesy Attributes, Operations, Associationsy Encapsulation, Inheritance

    y Unified Modelling Language

    y Object-Oriented Data Modellingy Identifying

    y Classes, attributes, and operations.y Associations among classes

    y

    Drawing class diagramsy Normalization

    y Introduction to ODMG 3.0 (the standard for Object-OrientedDatabases)

  • 8/8/2019 OODB CONCEPT

    3/38

  • 8/8/2019 OODB CONCEPT

    4/38

    Object-oriented databases

    y Avoid object-relational impedance mismatch

    y Provide a uniform data model

    y Combine features and properties of object-orientedsystems and languages

  • 8/8/2019 OODB CONCEPT

    5/38

    5

    Object-oriented concepts

    y Objectsy Objects represent real world entities,

    concepts, and tangible as well asintangible things.y For example a person, a drama, a licence

    y Every object has a unique identifier (OID).y A memory addressy System generatedy Never changes in the lifetime of the object

  • 8/8/2019 OODB CONCEPT

    6/38

  • 8/8/2019 OODB CONCEPT

    7/38

    7

    Object-oriented concepts

    y Objectsy An object is made of two things:

    y State: attributes (name, address, birthDate of a person)y Behaviour: operations (age of a person is computed from

    birthDate and current date)y Objects are categorized by their type or class.y An object is an instance of a type or class.

  • 8/8/2019 OODB CONCEPT

    8/38

    Object-oriented concepts

    y Sharing of objects through references

    y Two objects are identical if they have the same OID

    y Two objects are equal if they have the same state

  • 8/8/2019 OODB CONCEPT

    9/38

    9

    Object-oriented concepts

    y Classificationy Classification is the process of grouping together objects

    which have common features.y Programming languages have type systems and database

    systems have data models to classify object.y The name used for the classificatory group of values is

    usually called class .

    y

    Classy Provides a template for constructing objects.y Instances of a class have the same kind of data and

    identical behaviour.

  • 8/8/2019 OODB CONCEPT

    10/38

    10

    Object-oriented concepts

    y An Example of a class in UM L

    name: {Norman, William, Preston}address: StockportbirthDate: 11-JUN-70

    Person

    name: {firstName: string,middleName: string,lastName: string}

    address: stringbirthDate: date

    age(): Integer changeAddress(newAdd: string)

    Class Name

    Attributes

    Operations

    p:Person A Person object

  • 8/8/2019 OODB CONCEPT

    11/38

    11

    Object-oriented concepts

    y Encapsulationy Merger of data structure and

    operations.y Objects are composed of attributes

    (values) and operations(behaviour).

  • 8/8/2019 OODB CONCEPT

    12/38

    12

    Object-oriented concepts

    y Inheritancey A class can be defined

    in terms of another one.y Person is super-class

    and Student is sub-class.y

    Student class inheritsattributesand operations of Person.

    Person

    name: {firstName: string,

    middleName: string,lastName: string}address: stringbirthDate: date

    age(): Integer changeAddress(newAdd: string)

    Student

    regNum: string {PK}

    register(C: Course): boolean

    major: string

  • 8/8/2019 OODB CONCEPT

    13/38

    13

    Why ODBs?

    ODBs are inevitable when:Data is complex and variable in sizeComplex structural and compositional relationshipsData is highly inter-relatedData is evolving rapidly over timeRicher data types

    complex objectsinheritanceuser extensibility

    Behaviour with datanot just a data model but alsooperations can be bundled together with data

  • 8/8/2019 OODB CONCEPT

    14/38

    14

    Compari s on c ontinued

    RDB s vs. O DB s.Not very easy to compare because of philosophical differences.RDBs have only one construct i.e.Relation, whereas the type system of ODBs is much richer and complex.RDBs require primary keys and foreignkeys for implementing relationships, ODBs

    simply dont.

  • 8/8/2019 OODB CONCEPT

    15/38

    15

    Compari s on c ontinued

    RDB s vs. O DB s.ODBs support complex data whereasRDBs dont.ODBs support wide range of applications.ODBs are much faster than RDBs but areless mature to handle large volumes of data.There is more acceptance and dominationof RDBs in the market than that for ODBs.

  • 8/8/2019 OODB CONCEPT

    16/38

    UML

  • 8/8/2019 OODB CONCEPT

    17/38

    Defining Class A CLASS is a template (specification, blueprint)for a collection of objects that share a common

    set of attributes and operations.

    HealthClubMember

    Class

    Objects

    attributesoperations

  • 8/8/2019 OODB CONCEPT

    18/38

    R elationships A RELATIONSHIP is what a class or an object

    knows about another class or object.

    G eneralization (Class-to-Class) (Superclass/Subclass) InheritanceEx: Person - FacultyPerson, StudentPerson, Staff...

    Ex: ModesOfTravel - Airplane, Train, Auto, Cycle, Boat...[ Object] Associations

    FacultyInformation - CourseInformationStudentInformation - CourseInformation

    [ Object] Aggregations & Composition (Whole-Part) Assembly - Parts

    G roup - MembersContainer - Contents

  • 8/8/2019 OODB CONCEPT

    19/38

    U ML Class Diagram Notation

    M ember

    memberNumberfirstNamelastNametelephoneaddresscityetc...

    checkOutVideocheckInVideobuyItemetc...

    attributes

    operations

    {{

    Expanded view of aClass into its three

    sections:

    Top: Class Name

    Middle: attributes

    Bottom: operations

    Class

  • 8/8/2019 OODB CONCEPT

    20/38

    Generalization Relationships

    P ersonA generalization connects a subclassto its superclass. It denotes aninheritance of attributes and behaviorfrom the superclass to the subclass andindicates a specialization in the subclassof the more general superclass.

    Student

  • 8/8/2019 OODB CONCEPT

    21/38

  • 8/8/2019 OODB CONCEPT

    22/38

    22G eneralization (Class-to-Class)(superclass subclass; supertype subtype)

    y A G eneralization follows a is a or is a kind of heuristic from aspecialization class to the generalization class. (e.g., student is aperson, video is a kind of inventory).

    y Common attributes, operations and relationships are located in the

    generalization class and are inherited by the specialization classesy Unique attributes, operations and relationships are located in the

    specialization classes.

  • 8/8/2019 OODB CONCEPT

    23/38

  • 8/8/2019 OODB CONCEPT

    24/38

    24

    Person

    attributes

    operations

    Poor G eneralization Example(violates the is a or is a kind of heuristic)

    A rm

    attributes

    operations

    L eg

    attributes

    operations

    Head

    attributes

    operations

  • 8/8/2019 OODB CONCEPT

    25/38

    25

    Associations

    R elationships between instances(objects) of classesConceptual:

    associations can have two roles (bi-directional):

    source --> target target --> source

    roles have multiplicity (e.g., cardinality, constraints)To restrict navigation to one direction only, anarrowhead is used to indicate the navigation direction

    No inheritance as in generalizations

  • 8/8/2019 OODB CONCEPT

    26/38

    Multiplicity of Associationsy Multiplicity: refers to how many objects of one class can relate

    to each object of another class.

    Symbols used to indicate multiplicity in associations:

    Class

    Class

    Class

    Class

    Exactly one

    Zero or more*

    0..1 Optional (0 or 1)

    1.. * One or more

  • 8/8/2019 OODB CONCEPT

    27/38

    Software Design (UML)

    Association Relationships

    If two classes in a model need tocommunicate with each other, there mustbe link between them.

    An association denotes that link.

    InstructorStudent

  • 8/8/2019 OODB CONCEPT

    28/38

    Software Design (UML)

    Association Relationships (Contd)

    We can indicate the mu ltiplicity of an association by addingmu ltiplicity adorn m ents to the line denoting the association.

    The example indicates that a St u dent has one or more Instr u ctors :

    InstructorStudent 1 ..*

  • 8/8/2019 OODB CONCEPT

    29/38

    Software Design (UML)

    Association Relationships (Contd)

    The example indicates that every Instr u ctor has one or moreSt u dents :

    InstructorStudent 1 ..*

  • 8/8/2019 OODB CONCEPT

    30/38

    Software Design (UML)

    Association Relationships (Contd)

    We can also indicate the behavior of an object in an association( i.e., the role of an object) using rolena m es.

    InstructorStudent 1 ..*1 ..*

    learns fromteaches

  • 8/8/2019 OODB CONCEPT

    31/38

    Software Design (UML)

    Association Relationships (Contd)

    We can also name the association.

    TeamStudentmembership

    1 ..* 1 ..*

  • 8/8/2019 OODB CONCEPT

    32/38

  • 8/8/2019 OODB CONCEPT

    33/38

    Association Relationships (Contd)

    We can constrain the association relationship by defining thenavigability of the association. Here, a Ro u ter object requestsservices from a DNS object by sending messages to (invoking theoperations of) the server. The direction of the association indicatesthat the server has no knowledge of the Ro u ter .

    R outerDomainNameServer

  • 8/8/2019 OODB CONCEPT

    34/38

    Association Relationships (Contd)

    Associations can also be objects themselves, called link classes oran association classes .

    WarrantyP roduct

    R egistration

    modelNumberserialNumberwarrentyCode

  • 8/8/2019 OODB CONCEPT

    35/38

  • 8/8/2019 OODB CONCEPT

    36/38

    Software Design (UML)

    Association Relationships (Contd)

    We can model objects that contain other objects by way of specialassociations called aggregations and co m positions.

    An aggregation specifies a whole-part relationship between anaggregate (a whole) and a constituent part, where the part canexist independently from the aggregate. Aggregations are

    denoted by a hollow-diamond adornment on the association.

    Car

    Engine

    Transmission

  • 8/8/2019 OODB CONCEPT

    37/38

    Software Design (UML)

    Association Relationships (Contd)

    A co m position indicates a strong ownership and coincidentlifetime of parts by the whole ( i.e., they live and die as a whole).Compositions are denoted by a filled-diamond adornment on theassociation.

    Window

    Scrollbar

    Titlebar

    Menu

    1

    1

    1

    1

    1

    1 ..*

  • 8/8/2019 OODB CONCEPT

    38/38

    38

    Inventory

    Video Store UML Class Diagram

    SaleItem R entalItem

    Video Game ConcessionItem VCR

    Transaction Employee StoreLocation

    SaleTransaction R entalTransaction Suplier

    Member P urchaseOrder

    Sale R entalLineItemP urchaseOrderLineItem

    1

    0..*

    0..* 0..1 10..*

    1..*

    1 1

    1..*

    10..*

    10..*

    11..*

    1 0..*

    0..*

    1