EER vs. UML Terminology EER Diagram Entity Type Entity Attribute Domain Composite Attribute ~ [Derived Attribute] Relationship Type Relationship Instance Cardinality & Participation UML Class Diagram Class Object Attribute Domain Structured Domain Operation Association Link Multiplicities UML
EER Example Participation Department 1 Is In N Cardinality Employee N DNAME Cardinality Employee N NAME P# Assigned To M FNAME LNAME Project %TIME PNAME UML
Diagrams EER vs. UML Employee Employee … Entity Type vs. Class FNAME LNAME NAME Attributes Employee E# NAME: NameDom FNAME LNAME … Methods Structured Domain Entity Type vs. Class Attribute Composite Attribute vs. Structured Domain UML
EER vs. UML Complete Diagram Department D# DNAME … EER vs. UML Complete Diagram 1..1 Min participation (0 or some int n: n>0) 0..* D# Employee E# NAME: NameDom FNAME LNAME … Department Employee E# FNAME LNAME NAME Is In 1 DNAME N Max Cardinality N P# 0..* Assigned To AssignedTo %TIME M 0..* Project Project P# PNAME … %TIME PNAME UML
EER Derived Attributes - Include in Department the average salary of the employees in the department. Member Of Employee Department Salary AvgSal Class Method Department D# DNAME AvgSal UML
EER Multi-valued Attributes as Entity Major N Has Major 3 Student Major Student Major_Program UML Student … Major_Program Major … 0..* 0..3 UML
Weak Entities EER Weak Entity Name Employee Dependents Of Dependent SSN 1 N Dependent Name Employee SSN … UML Qualified Association UML
Aggregations Location Location Project Department No No Name No Name … Department Name No … 0..* 1..1 Location Name 1..* 0..* UML
Example: University Database Superclasses & Subclasses Generalization & Specialization Inheritance d disjoint o overlap total partial U superclass subclass EmpID Salary SSN Employee Degree Program U Person o U Grad Student Name U Student d U Superclass instance must always exist. Undergrad Student Major Dept Class UML
UML Superclass/Subclass Inheritance EER UML disjoint overlapping Employee EmpID Salary … d o Person SSN Name … GradStudent DegreeProgram … Student MajorDept … UndergradStudent Class … UML
Object-Oriented Approach Motivation Object-Oriented Databases (OODB) Add persistence to object-oriented programming languages Object Relational Databases (ORDBMS) Add user-defined methods to relational databases Allow grouping of relations into more complex “objects” UML
Relational is Good For Fixed format data Transaction processing: simple short transactions Concurrency control Recovery from crashes Query processing and Query optimization relational algebra and mathematical logic operations. UML
Problems The relational model has no notion of a single object. Context with the real world e.g., spatial context. Aggregation functions may be desired The notion of re-use cannot be exploited There may also be versions or variant configurations i.e variations of the same design. UML
Problems With the Relational Model - 1 Nonhomogeneous collection of design objects. Data Types: images, matrices, vectors; variable length. Temporal and/or spatial data. Many data types; few instances of each type. UML
Problems With the Relational Model - 2 Schemas evolve during design. Long running transactions: "checkout a design". Versions; design log. UML
Problems With the Relational Model - 3 Functions needed: Making a design permanent, Releasing design to production, Archiving design, etc. Library of design objects: minimize redundancy. UML
Object-Oriented Concepts - 1 Complex Objects: sets, bags, lists, arrays, tuples. UML
Object-Oriented Concepts - 2 Object Identity: identify by object id (oid) rather than by an attribute value, never changes. Encapsulation: Operations and Data available to user. Implementation hidden. No other operations available. UML
Object-Oriented Concepts - 3 Types and/or Classes: Type: Interface and Implementation. Types declared, checked at compile-time Class: Instances created at run-time UML
Object-Oriented Concepts - 4 Class or Type Hierarchies: Inheritance: both data and function example: student: undergraduate, graduate Overriding, overloading, and late binding: Polymorphism UML
Object-Oriented Concepts - 5 Computational Completeness: Extensibility: Means to define new types. User types not distinguished from system types. Persistence: Not present in OO programming languages. Should be implicit not explicit. UML
Object-Oriented Concepts - 6 Secondary Storage Management: Concurrency: Recovery: Ad Hoc Query Facility: UML
Review: Object State (value) Behavior (operations) Signature or interface: operation name and arguments Method or body: implementation Identified by unique Object Identifier (OID) UML
Class Group of similar objects Class hierarchies Inheritance Persistence must be specified explicitly Via entry point Via reachability UML
Type Hierarchies and Inheritance (EER – superclass/subclass relationship) PERSON: Name, Address, Birthdate, Age, SSN EMPLOYEE: subtype-of PERSON: Salary, HireDate, Seniority STUDENT: subtype-of PERSON: Major, GPA EMPLOYEE: Name, Address, Birthdate, Age, SSN, Salary, HireDate, Seniority STUDENT: Name, Address, Birthdate, Age, SSN, Major, GPA UML
Object Data Management Group (ODMG) Object Model Object Definition Language (ODL) Object Query Language (OQL) Bindings to object-oriented programming languages C++, Java, Smalltalk UML